🔖release 1.0.0 #5
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: CI/CD | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
check-release: | |
runs-on: ubuntu-latest | |
outputs: | |
should_release: ${{ steps.check_release_commit.outputs.should_release }} | |
version: ${{ steps.check_release_commit.outputs.version }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Check for release commit | |
id: check_release_commit | |
run: | | |
commit_message=$(git log --format=%B -n 1 ${{ github.sha }}) | |
if [[ $commit_message =~ 🔖[[:space:]]*release[[:space:]]+([0-9]+\.[0-9]+\.[0-9]+) ]]; then | |
echo "should_release=true" >> $GITHUB_OUTPUT | |
echo "version=${BASH_REMATCH[1]}" >> $GITHUB_OUTPUT | |
else | |
echo "should_release=false" >> $GITHUB_OUTPUT | |
fi | |
build: | |
needs: check-release | |
strategy: | |
matrix: | |
os: [macos-latest, ubuntu-latest, windows-latest] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- run: npm install | |
- run: xvfb-run -a npm test | |
if: runner.os == 'Linux' | |
- run: npm test | |
if: runner.os != 'Linux' | |
publish: | |
needs: [check-release, build] | |
runs-on: ubuntu-latest | |
if: needs.check-release.outputs.should_release == 'true' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 18.x | |
- run: npm install | |
- name: Update version in package.json | |
run: | | |
npm version ${{ needs.check-release.outputs.version }} --no-git-tag-version | |
- name: Publish to VS Code Marketplace | |
run: npm run deploy | |
env: | |
VSCE_PAT: ${{ secrets.VSCE_PAT }} | |
- name: Create GitHub Release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ needs.check-release.outputs.version }} | |
release_name: Release ${{ needs.check-release.outputs.version }} | |
draft: false | |
prerelease: false |