fix: npm publish --tag alpha when building an alpha release (#4112)
This updates our release process so that when we build an alpha of the Codex CLI (as determined by pushing a tag of the format `rust-v<cli-version>-alpha.<alpha-version>`), we will now publish the corresponding npm module publicly, but under the `alpha` tag. As you can see, this PR adds `--tag alpha` to the `npm publish` command, as appropriate.
This commit is contained in:
37
.github/workflows/rust-release.yml
vendored
37
.github/workflows/rust-release.yml
vendored
@@ -173,6 +173,8 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
version: ${{ steps.release_name.outputs.name }}
|
version: ${{ steps.release_name.outputs.name }}
|
||||||
tag: ${{ github.ref_name }}
|
tag: ${{ github.ref_name }}
|
||||||
|
should_publish_npm: ${{ steps.npm_publish_settings.outputs.should_publish }}
|
||||||
|
npm_tag: ${{ steps.npm_publish_settings.outputs.npm_tag }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
@@ -193,6 +195,25 @@ jobs:
|
|||||||
version="${GITHUB_REF_NAME#rust-v}"
|
version="${GITHUB_REF_NAME#rust-v}"
|
||||||
echo "name=${version}" >> $GITHUB_OUTPUT
|
echo "name=${version}" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
|
- name: Determine npm publish settings
|
||||||
|
id: npm_publish_settings
|
||||||
|
env:
|
||||||
|
VERSION: ${{ steps.release_name.outputs.name }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
version="${VERSION}"
|
||||||
|
|
||||||
|
if [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||||
|
echo "should_publish=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "npm_tag=" >> "$GITHUB_OUTPUT"
|
||||||
|
elif [[ "${version}" =~ ^[0-9]+\.[0-9]+\.[0-9]+-alpha\.[0-9]+$ ]]; then
|
||||||
|
echo "should_publish=true" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "npm_tag=alpha" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "should_publish=false" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "npm_tag=" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
# build_npm_package.py requires DotSlash when staging releases.
|
# build_npm_package.py requires DotSlash when staging releases.
|
||||||
- uses: facebook/install-dotslash@v2
|
- uses: facebook/install-dotslash@v2
|
||||||
- name: Stage npm package
|
- name: Stage npm package
|
||||||
@@ -227,8 +248,8 @@ jobs:
|
|||||||
# July 31, 2025: https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/
|
# July 31, 2025: https://github.blog/changelog/2025-07-31-npm-trusted-publishing-with-oidc-is-generally-available/
|
||||||
# npm docs: https://docs.npmjs.com/trusted-publishers
|
# npm docs: https://docs.npmjs.com/trusted-publishers
|
||||||
publish-npm:
|
publish-npm:
|
||||||
# Skip this step for pre-releases (alpha/beta).
|
# Publish to npm for stable releases and alpha pre-releases with numeric suffixes.
|
||||||
if: ${{ !contains(needs.release.outputs.version, '-') }}
|
if: ${{ needs.release.outputs.should_publish_npm == 'true' }}
|
||||||
name: publish-npm
|
name: publish-npm
|
||||||
needs: release
|
needs: release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -263,7 +284,17 @@ jobs:
|
|||||||
|
|
||||||
# No NODE_AUTH_TOKEN needed because we use OIDC.
|
# No NODE_AUTH_TOKEN needed because we use OIDC.
|
||||||
- name: Publish to npm
|
- name: Publish to npm
|
||||||
run: npm publish "${GITHUB_WORKSPACE}/dist/npm/codex-npm-${{ needs.release.outputs.version }}.tgz"
|
env:
|
||||||
|
VERSION: ${{ needs.release.outputs.version }}
|
||||||
|
NPM_TAG: ${{ needs.release.outputs.npm_tag }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
tag_args=()
|
||||||
|
if [[ -n "${NPM_TAG}" ]]; then
|
||||||
|
tag_args+=(--tag "${NPM_TAG}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
npm publish "${GITHUB_WORKSPACE}/dist/npm/codex-npm-${VERSION}.tgz" "${tag_args[@]}"
|
||||||
|
|
||||||
update-branch:
|
update-branch:
|
||||||
name: Update latest-alpha-cli branch
|
name: Update latest-alpha-cli branch
|
||||||
|
|||||||
Reference in New Issue
Block a user