Skip to content

Commit

Permalink
Added commit steps to create release
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisli30 committed Nov 5, 2024
1 parent 89cd884 commit c82992b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.CHRIS_PERSONAL_ACCESS_TOKEN }}
token: ${{ github.token }}

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -31,22 +31,28 @@ jobs:
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
npx changeset version
git push
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Version packages"
git push
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.CHRIS_PERSONAL_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}

- name: Check Version Change
id: version_check
env:
GITHUB_TOKEN: ${{ secrets.CHRIS_PERSONAL_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
LATEST_RELEASE=$(gh release list --limit 1 | cut -f1)
LATEST_VERSION=${LATEST_RELEASE#v}
echo "Current version: ${CURRENT_VERSION}"
echo "Latest release: ${LATEST_VERSION}"
if [ "$(printf '%s\n' "$LATEST_VERSION" "$CURRENT_VERSION" | sort -V | tail -n1)" = "$CURRENT_VERSION" ] && [ "$LATEST_VERSION" != "$CURRENT_VERSION" ]; then
echo "Version increment detected"
echo "should_release=true" >> $GITHUB_OUTPUT
Expand All @@ -59,7 +65,7 @@ jobs:
- name: Create GitHub Release
if: steps.version_check.outputs.should_release == 'true'
env:
GITHUB_TOKEN: ${{ secrets.CHRIS_PERSONAL_ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ github.token }}
run: |
CURRENT_VERSION=$(node -p "require('./package.json').version")
gh release create "v${CURRENT_VERSION}" \
Expand Down

0 comments on commit c82992b

Please sign in to comment.