-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
90 additions
and
0 deletions.
There are no files selected for viewing
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
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 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 Fetching origin... | ||
git fetch origin | ||
echo Pulling changes... | ||
git pull --rebase origin release | ||
echo Pushing version change... | ||
git push --follow-tags origin release | ||
# 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 |