opa-react: adopt tshy for dual mode builds (#106) #80
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
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 }} | |
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
with: | |
node-version: 21 | |
- name: Install Dependencies | |
run: npm ci | |
- 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@a74c6b72af54cfa997e81df42d94703d6313a2d0 # v2.0.6 | |
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@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2 | |
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@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 |