Skip to content

Commit

Permalink
Update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hidragos committed Sep 11, 2024
1 parent 7fe600e commit 2ccf3c3
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
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

0 comments on commit 2ccf3c3

Please sign in to comment.