Version Packages (#356) #198
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
name: Release | |
on: | |
push: | |
branches: | |
- main | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
jobs: | |
jsr: | |
name: Publish @styra/opa to JSR | |
runs-on: ubuntu-22.04 | |
needs: | |
- release | |
if: contains(fromJSON(needs.release.outputs.publishedPackages).*.name, '@styra/opa') | |
permissions: | |
contents: read | |
id-token: write # OIDC ID token for authentication with JSR | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
with: | |
node-version: 22 | |
- name: publish @styra/opa to JSR | |
run: | | |
npm ci | |
npx -w packages/opa jsr publish | |
release: | |
name: Release | |
outputs: | |
published: ${{ steps.changesets.outputs.published }} | |
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }} | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: write # to create release (changesets/action) | |
actions: write # to create tags (changesets/action) | |
issues: write # to post issue comments (changesets/action) | |
pull-requests: write # to create pull request (changesets/action) | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
with: | |
node-version: 22 | |
- name: Install Dependencies | |
run: | | |
npm ci | |
npm run build --ws | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: StyraInc/changesets-action@aba318e9165b45b7948c60273e0b72fce0a64eb9 # v1.4.7 | |
with: | |
publish: npm run publish | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Process results | |
id: opa_pkg | |
run: | | |
echo "tag=$(jq -nr --argjson pkgs $PP '$pkgs[] | select(.name == "@styra/opa") | (.name + "@" + .version)')" >> $GITHUB_OUTPUT | |
echo "included=$(jq -nr --argjson pkgs $PP '$pkgs[] | select(.name == "@styra/opa") | true')" >> $GITHUB_OUTPUT | |
echo "version=$(jq -nr --argjson pkgs $PP '$pkgs[] | select(.name == "@styra/opa") | .version')" >> $GITHUB_OUTPUT | |
env: | |
PP: ${{ steps.changesets.outputs.publishedPackages }} | |
- name: Generate @styra/opa GH release notes | |
run: build/opa-release-notes.sh > OPA_RELEASE_NOTES.md | |
if: steps.opa_pkg.outputs.included == 'true' | |
env: | |
VERSION: ${{ steps.opa_pkg.outputs.version }} | |
- name: Create @styra/opa GH release | |
uses: softprops/action-gh-release@e7a8f85e1c67a31e6ed99a94b41bd0b71bbee6b8 # v2.0.9 | |
if: steps.opa_pkg.outputs.included == 'true' | |
with: | |
body_path: OPA_RELEASE_NOTES.md | |
tag_name: ${{ steps.opa_pkg.outputs.tag }} | |
docs: | |
name: Publish Docs | |
needs: | |
- release | |
if: needs.release.outputs.published == 'true' | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
permissions: | |
actions: read | |
pages: write | |
id-token: write | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
- uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 | |
with: | |
node-version: 22 | |
- name: Install dependencies | |
run: | | |
npm ci | |
npm run build --ws | |
- name: Generate docs | |
run: npm run docs | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3.0.1 | |
with: | |
# Upload entire repository | |
path: docs/ | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4.0.5 |