Skip to content

Version Packages

Version Packages #513

name: Release Candidate
on:
push:
branches:
- 'changeset-release/**'
jobs:
release-candidate:
name: Candidate
if: ${{ github.repository == 'primer/primitives' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
- name: Set up Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'
- name: Install dependencies
run: npm ci --no-audit --no-fund --include=dev
- name: Build tokens
run: npm run build:tokens
- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
- name: Publish release candidate
run: |
version=$(jq -r .version package.json)
echo "$( jq ".version = \"$(echo $version)-rc.$(git rev-parse --short HEAD)\"" package.json )" > package.json
npm publish --tag next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Output candidate version number
id: commitStatus
uses: actions/github-script@v7
with:
script: |
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
github.rest.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: 'success',
context: `Published ${package.name}`,
description: package.version,
target_url: `https://unpkg.com/${package.name}@${package.version}/`
})
// Output the release version for next step
core.setOutput('packageVersion', package.version);
// Output the package name for next step
core.setOutput('packageName', package.name);
- name: Output candidate version to summary
env:
VERSION: ${{ steps.commitStatus.outputs.packageVersion }}
PACKAGE_NAME: ${{ steps.commitStatus.outputs.packageName }}
run: |
echo "### Latest release candidate" >> $GITHUB_STEP_SUMMARY
echo "[v$VERSION](https://unpkg.com/$PACKAGE_NAME@$VERSION/)" >> $GITHUB_STEP_SUMMARY