Skip to content

release

release #241

Workflow file for this run

name: release
on:
workflow_run:
workflows:
- check
types:
- completed
concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
jobs:
release:
name: Release package on NPM
runs-on: ubuntu-latest
if: github.event.workflow_run.conclusion == 'success' && github.ref_name == 'master' && startsWith(github.event.workflow_run.head_branch, 'v')
permissions:
contents: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Determine if version is prerelease
id: prerelease
env:
TYPE_GRAPHQL_VERSION: ${{ github.event.workflow_run.head_branch }}
run: |
_prerelease=
if printf "%s\n" "$TYPE_GRAPHQL_VERSION" | grep -q -P '^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$'; then
_prerelease=false
else
_prerelease=true
fi
printf 'value=%s\n' "$_prerelease" >> "$GITHUB_OUTPUT"
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22.x
registry-url: "https://registry.npmjs.org"
- name: Install latest npm
run: |
npm install -g npm@latest
- name: Install Dependencies
run: |
npm ci
- name: Prepare package
run: |
npm run prepublishOnly
env:
TYPE_GRAPHQL_REF: ${{ github.event.workflow_run.head_branch }}
- name: Build Changelog
id: changelog
uses: mikepenz/release-changelog-builder-action@v5
with:
configuration: "./.github/configs/changelog.json"
failOnError: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ github.event.workflow_run.head_branch }}
body: ${{ steps.changelog.outputs.changelog }}
prerelease: ${{ steps.prerelease.outputs.value == 'true' }}
- name: Publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
TYPE_GRAPHQL_PRERELEASE: ${{ steps.prerelease.outputs.value }}
run: |
_tag=
if [ "$TYPE_GRAPHQL_PRERELEASE" = "true" ]; then
_tag="next"
else
_tag="latest"
fi
npm publish --ignore-scripts --tag "$_tag"