11name : Build CLI Binaries
22
33on :
4+ workflow_dispatch : # Allow manual triggering (uses latest @neaps/cli release)
45 push :
56 release :
67 types : [published]
78
89jobs :
10+ resolve-tag :
11+ name : Resolve release tag
12+ runs-on : ubuntu-latest
13+ outputs :
14+ tag : ${{ steps.resolve.outputs.tag }}
15+ should_release : ${{ steps.resolve.outputs.should_release }}
16+ steps :
17+ - name : Resolve tag
18+ id : resolve
19+ env :
20+ GH_TOKEN : ${{ github.token }}
21+ run : |
22+ if [ "${{ github.event_name }}" = "release" ]; then
23+ TAG="${{ github.event.release.tag_name }}"
24+ if [[ "$TAG" == @neaps/cli@* ]]; then
25+ echo "tag=$TAG" >> "$GITHUB_OUTPUT"
26+ echo "should_release=true" >> "$GITHUB_OUTPUT"
27+ else
28+ echo "should_release=false" >> "$GITHUB_OUTPUT"
29+ fi
30+ elif [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
31+ TAG=$(gh api repos/${{ github.repository }}/releases --jq '[.[] | select(.tag_name | startswith("@neaps/cli@"))][0].tag_name')
32+ if [ -n "$TAG" ]; then
33+ echo "tag=$TAG" >> "$GITHUB_OUTPUT"
34+ echo "should_release=true" >> "$GITHUB_OUTPUT"
35+ else
36+ echo "should_release=false" >> "$GITHUB_OUTPUT"
37+ fi
38+ else
39+ echo "should_release=false" >> "$GITHUB_OUTPUT"
40+ fi
41+
942 build :
1043 name : Build ${{ matrix.target }}
44+ needs : resolve-tag
1145 runs-on : ${{ matrix.os }}
1246 strategy :
1347 matrix :
@@ -53,16 +87,19 @@ jobs:
5387 path : packages/cli/neaps-${{ matrix.target }}.*
5488
5589 - name : Upload to release
56- if : github.event_name == 'release '
90+ if : needs.resolve-tag.outputs.should_release == 'true '
5791 uses : softprops/action-gh-release@v2
92+ env :
93+ GITHUB_TOKEN : ${{ secrets.RELEASE_TOKEN }}
5894 with :
95+ tag_name : ${{ needs.resolve-tag.outputs.tag }}
5996 files : |
6097 packages/cli/neaps-${{ matrix.target }}.*
6198
6299 checksums :
63- if : github.event_name == 'release '
100+ if : needs.resolve-tag.outputs.should_release == 'true '
64101 name : Generate checksums
65- needs : build
102+ needs : [resolve-tag, build]
66103 runs-on : ubuntu-latest
67104 steps :
68105 - name : Download all artifacts
@@ -78,21 +115,24 @@ jobs:
78115
79116 - name : Upload checksums to release
80117 uses : softprops/action-gh-release@v2
118+ env :
119+ GITHUB_TOKEN : ${{ secrets.RELEASE_TOKEN }}
81120 with :
121+ tag_name : ${{ needs.resolve-tag.outputs.tag }}
82122 files : checksums.txt
83123
84124 update-homebrew :
85- if : github.event_name == 'release '
125+ if : needs.resolve-tag.outputs.should_release == 'true '
86126 name : Update Homebrew tap
87- needs : [build, checksums]
127+ needs : [resolve-tag, build, checksums]
88128 runs-on : ubuntu-latest
89129 steps :
90130 - name : Checkout
91131 uses : actions/checkout@v6
92132
93133 - name : Download release archives
94134 env :
95- VERSION : ${{ github.event.release.tag_name }}
135+ VERSION : ${{ needs.resolve-tag.outputs.tag }}
96136 run : |
97137 for target in darwin-arm64 linux-x64; do
98138 curl -fsSL -o "neaps-${target}.tar.gz" \
@@ -101,7 +141,7 @@ jobs:
101141
102142 - name : Generate formula
103143 env :
104- VERSION : ${{ github.event.release.tag_name }}
144+ VERSION : ${{ needs.resolve-tag.outputs.tag }}
105145 REPO : ${{ github.repository }}
106146 run : |
107147 SHA_DARWIN_ARM64=$(sha256sum neaps-darwin-arm64.tar.gz | cut -d' ' -f1)
@@ -118,12 +158,12 @@ jobs:
118158 env :
119159 GH_TOKEN : ${{ secrets.HOMEBREW_TAP_TOKEN }}
120160 run : |
121- git clone "https://x-access-token:${GH_TOKEN}@github.com/neaps /homebrew-tap.git" tap
161+ git clone "https://x-access-token:${GH_TOKEN}@github.com/openwatersio /homebrew-tap.git" tap
122162 mkdir -p tap/Formula
123163 cp neaps.rb tap/Formula/neaps.rb
124164 cd tap
125165 git config user.name "github-actions[bot]"
126166 git config user.email "github-actions[bot]@users.noreply.github.com"
127167 git add Formula/neaps.rb
128- git commit -m "Update neaps to ${{ github.event.release.tag_name }}"
168+ git commit -m "Update neaps to ${{ needs.resolve-tag.outputs.tag }}"
129169 git push
0 commit comments