Merge pull request #76 from REST-API-Client/ci/release-via-pr #33
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 and publish | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| test-and-bump: | |
| runs-on: ubuntu-latest | |
| if: ${{ !contains(github.event.head_commit.message, 'release/v') }} | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Run tests | |
| run: npm test | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Bump version and create release PR | |
| run: | | |
| npm version patch --no-git-tag-version | |
| VERSION=$(node -p "require('./package.json').version") | |
| BRANCH="release/v${VERSION}" | |
| git checkout -b "$BRANCH" | |
| git add package.json package-lock.json | |
| git commit -m "chore: release v${VERSION}" | |
| git push origin "$BRANCH" | |
| gh pr create --title "chore: release v${VERSION}" --body "Automated version bump to v${VERSION}" | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| publish: | |
| runs-on: ubuntu-latest | |
| if: ${{ contains(github.event.head_commit.message, 'release/v') }} | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Create and push tag | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| git tag "v${VERSION}" | |
| git push origin "v${VERSION}" | |
| - name: Install vsce | |
| run: npm i -g @vscode/vsce | |
| - name: Package extension | |
| run: vsce package | |
| - name: Publish to marketplace | |
| run: vsce publish -p "$PERSONAL_ACCESS_TOKEN" | |
| env: | |
| PERSONAL_ACCESS_TOKEN: ${{ secrets.VSCE_PAT }} |