Update release.yml #35
Workflow file for this run
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: 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 version to $(node -p "require('./package.json').version")" | |
echo Tagging version change... | |
VERSION=$(node -p "require('./package.json').version") | |
git tag -a "v$VERSION" -m "Release version $VERSION" | |
echo Fetching origin... | |
git fetch origin | |
echo Pulling changes... | |
git pull --rebase origin release | |
echo Pushing version change... | |
git push --follow-tags origin release | |
# Merge the release branch into main | |
git checkout main | |
git pull origin main | |
git merge release | |
git push | |
- name: Clean up release branch | |
run: | | |
git push origin --delete release |