π Release + Publish #19
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 + Publish | |
on: | |
workflow_dispatch: | |
inputs: | |
versionChange: | |
type: choice | |
description: Select the version change | |
required: true | |
default: 'minor' | |
options: | |
- major | |
- minor | |
- patch | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
env: | |
VERSION_CHANGE: ${{ github.event.inputs.versionChange }} | |
permissions: | |
contents: write | |
id-token: write | |
steps: | |
- name: β Use App Token for the Bot which is allowed to create releases | |
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1 | |
id: app-token | |
with: | |
app-id: ${{ vars.BOT_APP_ID }} | |
private-key: ${{ secrets.BOT_PRIVATE_KEY }} | |
- name: ποΈ Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.app-token.outputs.token }} | |
fetch-depth: 0 | |
- name: π Setup Platform | |
uses: oven-sh/setup-bun@v2 | |
with: | |
bun-version-file: .bun-version | |
- name: π¦ Install dependencies | |
run: | | |
bun install --frozen-lockfile | |
bun add -g npm | |
- name: β Update version | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git config --global push.followTags true | |
npm version ${{ env.VERSION_CHANGE }} -m "Release %s" | |
- name: π Get meta data | |
run: | | |
VERSION=$(bun --print "(await import('./package.json')).version") | |
NAME=$(bun --print "(await import('./package.json')).name") | |
DISPLAY_NAME=$(bun --print "(await import('./package.json')).displayName") | |
echo VERSION=$VERSION >> $GITHUB_ENV | |
echo NAME=$NAME >> $GITHUB_ENV | |
echo DISPLAY_NAME=$DISPLAY_NAME >> $GITHUB_ENV | |
- name: βοΈ Build | |
run: bun run build | |
- name: π Push tags | |
run: git push | |
- name: π Release ${{ env.VERSION }} | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: v${{ env.VERSION }} | |
name: ${{ env.DISPLAY_NAME }} v${{ env.VERSION }} | |
generate_release_notes: true | |
- name: π Publish to NPM Registry | |
run: | | |
npm set "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" | |
npm publish --provenance --access public |