v66#1-21-50 #21
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: Build and Release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Get the latest commit message | |
id: get_latest_commit | |
run: | | |
latest_commit=$(git log -1 --pretty=format:%s) | |
echo "latest_commit_message=$latest_commit" >> $GITHUB_ENV | |
- name: Read changelog | |
id: read_changelog | |
run: | | |
changelog=$(< CHANGELOG.md) | |
echo "CHANGELOG<<EOF" >> $GITHUB_ENV | |
echo "$changelog" >> $GITHUB_ENV | |
echo "EOF" >> $GITHUB_ENV | |
- name: Set up Node.js | |
if: startsWith(env.latest_commit_message, 'v') | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '22' | |
- name: Install dependencies | |
if: startsWith(env.latest_commit_message, 'v') | |
run: npm i | |
- name: npm run build | |
if: startsWith(env.latest_commit_message, 'v') | |
run: npm run build | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
# Check if commit message starts with 'v' | |
if: startsWith(env.latest_commit_message, 'v') | |
with: | |
tag_name: ${{ github.ref }} | |
name: Release ${{ env.latest_commit_message }} | |
body: ${{ env.CHANGELOG }} | |
draft: false | |
prerelease: false | |
files: build/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |