Skip to content

Commit

Permalink
refactor the publish job (#181)
Browse files Browse the repository at this point in the history
* refactor: change job name to publish-github

* refactor: don’t fail if we don’t have to release
  • Loading branch information
compojoom authored Jun 25, 2024
1 parent b0984c0 commit 7e4cb8b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- main

jobs:
publish-npm:
publish-github:
runs-on: ubuntu-latest
steps:
- name: Checkout
Expand All @@ -20,7 +20,9 @@ jobs:
OLD_VERSION=$(git describe --tags --abbrev=0)
NEW_VERSION_NUMBER_ONLY=$(node -p 'require("./package.json").version')
NEW_VERSION=v${NEW_VERSION_NUMBER_ONLY}
if [ $NEW_VERSION != $OLD_VERSION ]; then
echo "OLD_VERSION=$OLD_VERSION" >> $GITHUB_ENV
echo "NEW_VERSION=$NEW_VERSION" >> $GITHUB_ENV
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
echo "New version $NEW_VERSION detected"
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
git log "$OLD_VERSION"..HEAD --pretty=format:"* %s" --invert-grep --grep="$NEW_VERSION_NUMBER_ONLY" > CHANGELOG.md
Expand All @@ -29,20 +31,18 @@ jobs:
fi
- name: Create a git tag
if: steps.version.outputs.version
if: env.NEW_VERSION != env.OLD_VERSION
run: git tag $NEW_VERSION && git push --tags
env:
NEW_VERSION: ${{ steps.version.outputs.version }}

- name: GitHub release
if: steps.version.outputs.version
if: env.NEW_VERSION != env.OLD_VERSION
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: false
release_name: ${{ steps.version.outputs.version }}
tag_name: ${{ steps.version.outputs.version }}
release_name: ${{ env.NEW_VERSION }}
tag_name: ${{ env.NEW_VERSION }}
body_path: CHANGELOG.md
env:
GITHUB_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit 7e4cb8b

Please sign in to comment.