Skip to content

Commit

Permalink
Merge pull request #478 from EvanNotFound/dev
Browse files Browse the repository at this point in the history
ci: improve release workflow and automate version management
  • Loading branch information
EvanNotFound authored Dec 2, 2024
2 parents ca51c33 + 115443d commit 13ba3e8
Showing 1 changed file with 26 additions and 20 deletions.
46 changes: 26 additions & 20 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,37 +48,43 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Merge dev into main
- name: Create Release Branch and Update Version
run: |
git checkout main
git merge origin/dev
VERSION=$(node -p "require('./package.json').version")
BRANCH="release/v${VERSION}"
git checkout -b $BRANCH
npm run release:${{ github.event.inputs.release-type }}
- name: Create Release
run: npm run release:${{ github.event.inputs.release-type }}

- name: Update package-lock.json
run: npm install

- name: Commit package-lock.json if changed
- name: Commit Changes
run: |
VERSION=$(node -p "require('./package.json').version")
if [[ -n "$(git status --porcelain package-lock.json)" ]]; then
git add package-lock.json
git commit -m "chore: bump version to ${VERSION}"
fi
NEW_VERSION=$(node -p "require('./package.json').version")
git add package.json package-lock.json
git commit -m "chore: bump version to ${NEW_VERSION}"
git push -u origin $BRANCH
- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(node -p "require('./package.json').version")
BRANCH="release/v${VERSION}"
git checkout -b $BRANCH
git push -u origin $BRANCH
gh pr create --base main --head $BRANCH --title "Release v${VERSION}" --body "Automated release PR for version ${VERSION}"
NEW_VERSION=$(node -p "require('./package.json').version")
gh pr create --base main --head "release/v${NEW_VERSION}" --title "Release v${NEW_VERSION}" --body "Automated release PR for version ${NEW_VERSION}"
- name: Create GitHub Release (Draft)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
NEW_VERSION=$(node -p "require('./package.json').version")
gh release create "v${NEW_VERSION}" \
--draft \
--title "v${NEW_VERSION}" \
--notes "Release v${NEW_VERSION}"
- name: Update dev branch
run: |
NEW_VERSION=$(node -p "require('./package.json').version")
git checkout dev
git merge $BRANCH
git merge "release/v${NEW_VERSION}"
git push origin dev

0 comments on commit 13ba3e8

Please sign in to comment.