Skip to content

Update release.yml

Update release.yml #26

Workflow file for this run

name: Release Workflow
on:
push:
branches:
- release
permissions:
contents: write
actions: write
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm install
- name: Build for production
run: npm run build --omit=dev
- name: Configure Git
run: |
git checkout release
git pull origin release
git config --global user.name 'GitHub Actions'
git config --global user.email 'actions@github.com'
- name: Ensure clean working directory
run: |
git status --porcelain
if [ -n "$(git status --porcelain)" ]; then
echo "Working directory is not clean. Stashing changes..."
git stash -u
fi
- name: Bump version and tag release
run: |
# Bump the version
npm version patch --no-git-tag-version -m "Bump version to %s"
# # Check if the tag already exists
# if git rev-parse "v$VERSION" >/dev/null 2>&1; then
# echo "Tag v$VERSION already exists. Deleting it."
# git tag -d "v$VERSION"
# git push origin --delete "v$VERSION"
# fi
git stage -A
echo Fetching origin...
git fetch origin
echo Pulling changes...
git pull origin HEAD:release
echo Committing version change...
git commit -m "Bump web version to %updatedVersion%" -m "[skip ci]"
echo Tagging version change...
git tag -a "web-%updatedVersion%" -m "web-%updatedVersion%"
echo Pushing version change...
git push --follow-tags origin HEAD:$(Build.SourceBranch)
# Commit the changes with a message
git commit -m "Bump version to $(node -p "require('./package.json').version")"
# Create a new tag for the release
VERSION=$(node -p "require('./package.json').version")
git tag -a "v$VERSION" -m "Release version $VERSION"
# Push the commit and the tag to the remote repository
git push origin HEAD:main
git push origin "v$VERSION"
- name: Clean up release branch
run: |
git push origin --delete origin/release