CI build #443
This file contains hidden or 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
| # build, create a release, and publish to npm after successful CI | |
| name: CI build | |
| on: | |
| workflow_run: | |
| workflows: | |
| - "CI" | |
| types: | |
| - "completed" | |
| branches: [master] | |
| jobs: | |
| on-success: | |
| runs-on: ubuntu-latest | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| permissions: | |
| contents: write | |
| id-token: write | |
| steps: | |
| - name: Generate release token | |
| id: app-token | |
| uses: actions/create-github-app-token@v3 | |
| with: | |
| app-id: ${{ secrets.RELEASE_APP_ID }} | |
| private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: master | |
| fetch-depth: 0 | |
| token: ${{ steps.app-token.outputs.token }} | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| cache: 'npm' | |
| registry-url: 'https://registry.npmjs.org' | |
| - run: corepack enable npm && corepack prepare npm@11.13.0 --activate | |
| # build dist folder | |
| - run: npm ci | |
| - run: npm run build | |
| - name: Set up Git commit author | |
| run: | | |
| git config --local user.name "bitsocial-release-bot[bot]" | |
| git config --local user.email "3419549+bitsocial-release-bot[bot]@users.noreply.github.com" | |
| - name: Get current version | |
| id: before | |
| run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT | |
| - name: Create Github Release | |
| env: | |
| GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} | |
| run: npm run release -- --ci | |
| - name: Check if released | |
| id: release | |
| run: | | |
| AFTER=$(node -p "require('./package.json').version") | |
| if [ "${{ steps.before.outputs.version }}" != "$AFTER" ]; then | |
| echo "Released v$AFTER" | |
| echo "released=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "No new version to release" | |
| echo "released=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Publish to npm | |
| if: steps.release.outputs.released == 'true' | |
| run: npx --yes npm@latest publish --access public --provenance |