Set prerelease true on node.js.yml #20
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 Source Code | |
on: | |
push: | |
branches: ["main"] | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [18.x, 20.x, 22.x] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: 'npm' | |
- run: npm ci | |
- run: npm run build --if-present | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Latest Release Version | |
id: get_version | |
run: | | |
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.0.0") | |
if [[ $LATEST_TAG =~ v([0-9]+)\.([0-9]+)\.([0-9]+) ]]; then | |
MAJOR=${BASH_REMATCH[1]} | |
MINOR=${BASH_REMATCH[2]} | |
PATCH=${BASH_REMATCH[3]} | |
PATCH=$((PATCH + 1)) | |
TAG_NAME="v${MAJOR}.${MINOR}.${PATCH}" | |
else | |
TAG_NAME="v1.0.1" # Fallback if no valid tag is found | |
fi | |
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV | |
- name: Create Git Tag | |
run: | | |
git tag ${{ env.TAG_NAME }} | |
git push origin ${{ env.TAG_NAME }} | |
- name: Get Changelog | |
id: changelog | |
run: | | |
CHANGELOG=$(git log --pretty=format:'- %s' $(git describe --tags --abbrev=0)..HEAD) | |
echo "CHANGELOG=$CHANGELOG" >> $GITHUB_ENV | |
- name: Create GitHub Release | |
uses: softprops/[email protected] | |
with: | |
tag_name: ${{ env.TAG_NAME }} | |
body: | | |
## Changelog | |
${{ env.CHANGELOG }} | |
prerelease: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |