feat: enable manual triggering of GitHub Pages deployment workflow [s… #7
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
| name: Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| permissions: | |
| contents: write | |
| id-token: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check for skip release | |
| id: check_skip | |
| run: | | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if [[ $COMMIT_MSG == *"[skip release]"* ]]; then | |
| echo "skip=true" >> $GITHUB_OUTPUT | |
| echo "Skipping release due to [skip release] in commit message" | |
| else | |
| echo "skip=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Node.js | |
| if: steps.check_skip.outputs.skip != 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install pnpm | |
| if: steps.check_skip.outputs.skip != 'true' | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Install dependencies | |
| if: steps.check_skip.outputs.skip != 'true' | |
| run: pnpm install | |
| - name: Build project | |
| if: steps.check_skip.outputs.skip != 'true' | |
| run: pnpm build | |
| - name: Run tests | |
| if: steps.check_skip.outputs.skip != 'true' | |
| run: pnpm test | |
| - name: Configure Git | |
| if: steps.check_skip.outputs.skip != 'true' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump version | |
| if: steps.check_skip.outputs.skip != 'true' | |
| id: version | |
| run: | | |
| # Check commit message for version bump type | |
| COMMIT_MSG=$(git log -1 --pretty=%B) | |
| if [[ $COMMIT_MSG == *"[major]"* ]]; then | |
| VERSION_TYPE="major" | |
| elif [[ $COMMIT_MSG == *"[minor]"* ]]; then | |
| VERSION_TYPE="minor" | |
| else | |
| VERSION_TYPE="patch" | |
| fi | |
| echo "Version type: $VERSION_TYPE" | |
| # Bump version | |
| npm version $VERSION_TYPE -m "chore: release %s [skip ci]" | |
| # Get new version | |
| NEW_VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| - name: Push changes | |
| if: steps.check_skip.outputs.skip != 'true' | |
| run: | | |
| git push origin master --follow-tags | |
| - name: Create GitHub Release | |
| if: steps.check_skip.outputs.skip != 'true' | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Release v${{ steps.version.outputs.version }} | |
| generate_release_notes: true | |
| - name: Publish to npm | |
| if: steps.check_skip.outputs.skip != 'true' | |
| run: npm publish --access public --provenance | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |