@@ -129,34 +129,34 @@ jobs:
129129 runs-on : ubuntu-latest
130130 needs : checksums
131131 if : startsWith(github.ref, 'refs/tags/v')
132+ env :
133+ CRATES_IO_TOKEN : ${{ secrets.CRATES_IO_TOKEN }}
132134 steps :
133135 - name : Checkout
134136 uses : actions/checkout@v4
135137
136138 - name : Install Rust toolchain
137139 uses : dtolnay/rust-toolchain@stable
138140
139- - name : Skip when CRATES_IO_TOKEN is missing
140- if : ${{ secrets.CRATES_IO_TOKEN == '' }}
141- run : echo "CRATES_IO_TOKEN is not configured; skipping crates.io publish."
142-
143- - name : Verify Cargo version matches tag
144- if : ${{ secrets.CRATES_IO_TOKEN != '' }}
141+ - name : Publish crate (if token exists)
145142 run : |
146143 set -euxo pipefail
144+ if [ -z "${CRATES_IO_TOKEN}" ]; then
145+ echo "CRATES_IO_TOKEN is not configured; skipping crates.io publish."
146+ exit 0
147+ fi
147148 tag="${GITHUB_REF_NAME#v}"
148149 cargo_version=$(grep -E '^version\\s*=\\s*\"' Cargo.toml | head -n1 | sed -E 's/.*\"([^\"]+)\".*/\\1/')
149150 test "$tag" = "$cargo_version"
150-
151- - name : Publish crate
152- if : ${{ secrets.CRATES_IO_TOKEN != '' }}
153- run : cargo publish --locked --token "${{ secrets.CRATES_IO_TOKEN }}"
151+ cargo publish --locked --token "${CRATES_IO_TOKEN}"
154152
155153 publish-npm :
156154 name : Publish npm package
157155 runs-on : ubuntu-latest
158156 needs : publish
159157 if : startsWith(github.ref, 'refs/tags/v')
158+ env :
159+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
160160 steps :
161161 - name : Checkout
162162 uses : actions/checkout@v4
@@ -167,44 +167,34 @@ jobs:
167167 node-version : " 20"
168168 registry-url : " https://registry.npmjs.org"
169169
170- - name : Skip when NPM_TOKEN is missing
171- if : ${{ secrets.NPM_TOKEN == '' }}
172- run : echo "NPM_TOKEN is not configured; skipping npm publish."
173-
174- - name : Verify npm package version matches tag
175- if : ${{ secrets.NPM_TOKEN != '' }}
170+ - name : Publish npm package (if token exists)
176171 run : |
177172 set -euxo pipefail
173+ if [ -z "${NPM_TOKEN}" ]; then
174+ echo "NPM_TOKEN is not configured; skipping npm publish."
175+ exit 0
176+ fi
178177 tag="${GITHUB_REF_NAME#v}"
179178 npm_version=$(node -p "require('./npm/tu/package.json').version")
180179 test "$tag" = "$npm_version"
181-
182- - name : Publish npm package
183- if : ${{ secrets.NPM_TOKEN != '' }}
184- working-directory : npm/tu
185- run : npm publish --access public
186- env :
187- NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
180+ cd npm/tu
181+ NODE_AUTH_TOKEN="${NPM_TOKEN}" npm publish --access public
188182
189183 publish-homebrew-tap :
190184 name : Publish Homebrew tap formula
191185 runs-on : ubuntu-latest
192186 needs : checksums
193187 if : startsWith(github.ref, 'refs/tags/v')
188+ env :
189+ HOMEBREW_TAP_PAT : ${{ secrets.HOMEBREW_TAP_PAT }}
194190 steps :
195- - name : Skip when HOMEBREW_TAP_PAT is missing
196- if : ${{ secrets.HOMEBREW_TAP_PAT == '' }}
197- run : echo "HOMEBREW_TAP_PAT is not configured; skipping Homebrew publish."
198-
199191 - name : Download release bundle
200- if : ${{ secrets.HOMEBREW_TAP_PAT != '' }}
201192 uses : actions/download-artifact@v4
202193 with :
203194 name : tu-release-bundle
204195 path : dist
205196
206197 - name : Generate Formula
207- if : ${{ secrets.HOMEBREW_TAP_PAT != '' }}
208198 run : |
209199 set -euxo pipefail
210200 version="${GITHUB_REF_NAME#v}"
@@ -247,10 +237,13 @@ jobs:
247237 RUBY
248238
249239 - name : Update tap repository
250- if : ${{ secrets.HOMEBREW_TAP_PAT != '' }}
251240 run : |
252241 set -euxo pipefail
253- git clone "https://x-access-token:${{ secrets.HOMEBREW_TAP_PAT }}@github.com/${HOMEBREW_TAP_REPO}.git" tap
242+ if [ -z "${HOMEBREW_TAP_PAT}" ]; then
243+ echo "HOMEBREW_TAP_PAT is not configured; skipping Homebrew publish."
244+ exit 0
245+ fi
246+ git clone "https://x-access-token:${HOMEBREW_TAP_PAT}@github.com/${HOMEBREW_TAP_REPO}.git" tap
254247 mkdir -p tap/Formula
255248 cp out/Formula/tu.rb tap/Formula/tu.rb
256249 cd tap
0 commit comments