Skip to content

ci: don't hardcode packages #54

ci: don't hardcode packages

ci: don't hardcode packages #54

Workflow file for this run

name: Release
on:
push:
branches:
- main
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
jsr:
name: Publish @styra/opa to JSR
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write # OIDC ID token for authentication with JSR
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 21
- name: publish @styra/opa to JSR
run: |
npm ci
npx -w packages/opa jsr publish
release:
name: Release
outputs:
published: ${{ steps.changesets.outputs.published }}
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@v4
- uses: actions/setup-node@v4
with:
node-version: 21
- name: Install Dependencies
run: npm ci
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
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
# This takes the last block (by record separator "\n## ") and removes the first line (timestamp)
run: |
awk 'BEGIN { RS="\n## "} END { print $0 }' packages/opa/RELEASES.md | tail +2 > OPA_RELEASE_NOTES.md
echo "\n- [NPM ${{ steps.opa_pkg.version }}](https://www.npmjs.com/package/@styra/opa/v/${{ steps.opa_pkg.version }})" >> OPA_RELEASE_NOTES.md
cat OPA_RELEASE_NOTES.md
if: steps.opa_pkg.included == 'true'
- name: Create @styra/opa GH release
uses: softprops/action-gh-release@v2
if: steps.opa_pkg.included == 'true'
with:
body_path: OPA_RELEASE_NOTES.md
tag_name: ${{ steps.opa_pkg.tag }}
docs:
name: Publish Docs
needs:
- release
if: needs.release.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@v4
- uses: actions/setup-node@v4
with:
node-version: 21
- name: Install dependencies
run: npm ci
- name: Generate docs
run: npm run docs
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: docs/
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4