feat: add auth login and access token handling #79
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# semantic-release action | |
# Derived from https://semantic-release.gitbook.io/semantic-release/recipes/ci-configurations/github-actions | |
name: release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
types: [opened, synchronize, reopened] | |
permissions: | |
contents: read # for checkout | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
- name: Install dependencies | |
run: npm clean-install | |
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies | |
run: npm audit signatures | |
- name: Build | |
env: | |
NOVA_AUTH0_DEV_CLIENT_ID: ${{ secrets.NOVA_AUTH0_DEV_CLIENT_ID }} | |
NOVA_AUTH0_STG_CLIENT_ID: ${{ secrets.NOVA_AUTH0_STG_CLIENT_ID }} | |
NOVA_AUTH0_PROD_CLIENT_ID: ${{ secrets.NOVA_AUTH0_PROD_CLIENT_ID }} | |
run: npm run build | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-artifacts | |
path: dist/ | |
build-and-release: | |
runs-on: ubuntu-latest | |
needs: setup | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
permissions: | |
contents: write # to be able to publish a GitHub release | |
issues: write # to be able to comment on released issues | |
pull-requests: write # to be able to comment on released pull requests | |
id-token: write # to enable use of OIDC for npm provenance | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-artifacts | |
path: dist/ | |
- name: Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npx semantic-release | |
publish-snapshot: | |
runs-on: ubuntu-latest | |
needs: setup | |
if: github.event_name == 'pull_request' | |
permissions: | |
contents: write # to be able to publish a GitHub release | |
issues: write # to be able to comment on released issues | |
pull-requests: write # to be able to comment on released pull requests | |
id-token: write # to enable use of OIDC for npm provenance | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: "lts/*" | |
- name: Download build artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: build-artifacts | |
path: dist/ | |
- name: Configure npm authentication | |
run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc | |
- name: Install semantic-release | |
run: npm install semantic-release | |
- name: Determine next version | |
id: next_version | |
run: | | |
# Determine the next version using semantic-release | |
npx semantic-release --dry-run | |
NEXT_VERSION=$(npx semantic-release --dry-run | grep "The next release version is" | sed -E 's/.*The next release version is ([0-9]+\.[0-9]+\.[0-9]+).*/\1/') | |
echo "NEXT_VERSION=$NEXT_VERSION" >> $GITHUB_ENV | |
- name: Update package.json version | |
env: | |
NEXT_VERSION: ${{ env.NEXT_VERSION }} | |
run: | | |
# Extract the pull request number | |
PR_NUMBER=$(echo $GITHUB_REF | sed 's/refs\/pull\/\([0-9]*\)\/.*/\1/') | |
# Extract the branch name | |
BRANCH_NAME=$(echo $GITHUB_HEAD_REF | sed 's/\//-/g') | |
# Create a snapshot version with branch name and PR number | |
SNAPSHOT_VERSION="${NEXT_VERSION}-pr-${BRANCH_NAME}-${PR_NUMBER}" | |
# Update the package.json with the new version | |
jq --arg version "$SNAPSHOT_VERSION" '.version = $version' package.json > package.tmp.json && mv package.tmp.json package.json | |
- name: Publish snapshot to npm | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: | | |
# Publish the snapshot version | |
npm publish --tag snapshot |