|
1 | 1 | name: Publish release |
2 | 2 |
|
3 | 3 | on: |
4 | | - push: |
5 | | - branches: |
6 | | - - master |
7 | | - tags: |
8 | | - - "v*" |
| 4 | + workflow_dispatch: |
9 | 5 |
|
10 | 6 | permissions: |
11 | | - contents: write |
12 | 7 | id-token: write |
13 | 8 |
|
14 | 9 | jobs: |
15 | | - check_release: |
16 | | - name: Check release conditions |
17 | | - runs-on: ubuntu-latest |
18 | | - outputs: |
19 | | - should_release: ${{ steps.check.outputs.should_release }} |
20 | | - steps: |
21 | | - - name: 📚 Git Checkout |
22 | | - uses: actions/checkout@v6 |
23 | | - |
24 | | - - name: Check conditions |
25 | | - id: check |
26 | | - env: |
27 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
28 | | - run: | |
29 | | - if [[ "${{ github.ref }}" == refs/tags/v* ]]; then |
30 | | - echo "Proceeding with tag release" |
31 | | - echo "should_release=true" >> $GITHUB_OUTPUT |
32 | | - elif [[ "${{ github.ref }}" == refs/heads/master ]]; then |
33 | | - # Find the PR associated with the merge commit that has 'release' label |
34 | | - PR_COUNT=$(gh pr list --search "${{ github.sha }}" --state merged --label release --json number --jq 'length') |
35 | | - if [[ "$PR_COUNT" -gt 0 ]]; then |
36 | | - echo "Proceeding with release labeled PR" |
37 | | - echo "should_release=true" >> $GITHUB_OUTPUT |
38 | | - else |
39 | | - echo "No release label found on merged PR, skipping." |
40 | | - echo "should_release=false" >> $GITHUB_OUTPUT |
41 | | - fi |
42 | | - else |
43 | | - echo "should_release=false" >> $GITHUB_OUTPUT |
44 | | - fi |
45 | | -
|
46 | | - release_gh: |
47 | | - name: GitHub Release |
48 | | - needs: check_release |
49 | | - if: needs.check_release.outputs.should_release == 'true' |
50 | | - runs-on: ubuntu-latest |
51 | | - steps: |
52 | | - - name: 📚 Git Checkout |
53 | | - uses: actions/checkout@v6 |
54 | | - |
55 | | - - name: Get latest version |
56 | | - run: | |
57 | | - echo "PACKAGE_VERSION=$(grep '^version: ' pubspec.yaml | cut -d ' ' -f 2 | tr -d '\r')" >> $GITHUB_ENV |
58 | | -
|
59 | | - - name: Download dSYMs |
60 | | - if: github.ref == 'refs/heads/master' |
61 | | - env: |
62 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
63 | | - run: | |
64 | | - PR_BODY=$(gh pr list --search "${{ github.sha }}" --state merged --json body --jq '.[0].body') |
65 | | - url=$(echo "$PR_BODY" | grep -oE 'https://[^ )]*dSYMs\.zip' | head -n 1) |
66 | | - if [ -n "$url" ]; then |
67 | | - echo "Found dSYMs URL: $url" |
68 | | - curl -L -o dSYMs.zip "$url" |
69 | | - else |
70 | | - echo "No dSYMs.zip URL found in PR body." |
71 | | - fi |
72 | | -
|
73 | | - - name: Generate Changelog |
74 | | - run: awk '/^## \[/{if (f) exit; f=1; next} f' CHANGELOG.md > RELEASE_NOTES.md |
75 | | - |
76 | | - - name: GitHub Release |
77 | | - env: |
78 | | - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
79 | | - run: | |
80 | | - FILES="" |
81 | | - if [ -f dSYMs.zip ]; then |
82 | | - FILES="dSYMs.zip" |
83 | | - fi |
84 | | - gh release create v${{ env.PACKAGE_VERSION }} \ |
85 | | - --title "freeRASP ${{ env.PACKAGE_VERSION }}" \ |
86 | | - --notes-file RELEASE_NOTES.md \ |
87 | | - $FILES || echo "" |
88 | | -
|
89 | 10 | publish_pub_dev: |
90 | 11 | name: Publish release to pub.dev |
91 | | - needs: release_gh |
92 | 12 | runs-on: ubuntu-latest |
93 | 13 | steps: |
94 | 14 | - name: 📚 Git Checkout |
|
0 commit comments