Skip to content

Refactor workflow to integrate CI/CD #1

Refactor workflow to integrate CI/CD

Refactor workflow to integrate CI/CD #1

Workflow file for this run

name: Release
on:
workflow_call:
secrets:
NPM_TOKEN:
required: true
description: The token to publish to npm
GITHUB_TOKEN:

Check failure on line 9 in .github/workflows/.release.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/.release.yaml

Invalid workflow file

secret name `GITHUB_TOKEN` within `workflow_call` can not be used since it would collide with system reserved name
required: true
description: The token to create a release on GitHub
jobs:
# Release the package to npm
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write # Used to commit to "Version Packages" PR
pull-requests: write # Used to create "Version Packages" PR
id-token: write # Used to publish to npm with provenance statements
# Other permissions are defaulted to none
steps:
- name: Checkout Repo
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup
uses: ./.github/actions/setup
with:
skip-rust-setup: 'true'
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7
with:
publish: pnpm exec changeset publish
version: pnpm exec changeset version
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
outputs:
published: ${{ steps.changesets.outputs.published }}
# If the release job not published, run this job to publish a prerelease
prerelease:
name: Prerelease
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
needs: release
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup
uses: ./.github/actions/setup
with:
skip-rust-setup: 'true'
- uses: actions/download-artifact@65a9edc5881444af0b9093a5e628f2fe47ea3b2e # v4.1.7
- name: Creating .npmrc
if: ${{ github.actor != 'dependabot[bot]' }}
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: "Release @next"
run: |
pnpm exec changeset version --snapshot next
pnpm exec changeset publish --no-git-tag --snapshot --tag next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# This job is used to deploy the documentation to GitHub Pages
doc:
runs-on: ubuntu-latest
# if the release job was successful, run this job
needs:
- release
if: needs.release.outputs.published == 'true'
concurrency:
group: GitHub Pages
cancel-in-progress: true
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
permissions:
contents: read
pages: write
id-token: write
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
- name: Setup
uses: ./.github/actions/setup
with:
skip-rust-setup: 'true'
- name: Build documentation
run: pnpm run doc
- name: Configure GitHub Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5.0.0
- name: Upload GitHub Pages artifact
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1
with:
path: doc
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5