Skip to content

Commit

Permalink
ci: fix release with merge commit (#51)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Jan 30, 2025
1 parent f153eea commit d45598d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
21 changes: 21 additions & 0 deletions .changeset/commit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const { execSync } = require('node:child_process')

const getSignedOffBy = () => {
const gitUserName = execSync('git config user.name').toString('utf-8').trim()
const gitEmail = execSync('git config user.email').toString('utf-8').trim()

return `Signed-off-by: ${gitUserName} <${gitEmail}>`
}

const getAddMessage = async (changeset) => {
return `docs(changeset): ${changeset.summary}\n\n${getSignedOffBy()}\n`
}

const getVersionMessage = async () => {
return `chore(release): new version\n\n${getSignedOffBy()}\n`
}

module.exports = {
getAddMessage,
getVersionMessage,
}
1 change: 1 addition & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": "./commit",
"privatePackages": false,
"fixed": [["@animo-id/*"]],
"access": "public",
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ jobs:
release-stable:
runs-on: ubuntu-20.04
name: Release Stable
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand All @@ -25,7 +27,7 @@ jobs:
- name: Install Dependencies
run: pnpm install --frozen-lockfile

- name: Create Release Pull Request
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
Expand All @@ -42,15 +44,16 @@ jobs:
run: echo "CURRENT_PACKAGE_VERSION=$(node -p "require('./package.json').version")" >> $GITHUB_ENV

- name: Create Github Release
if: "startsWith(github.event.head_commit.message, 'chore(release): new version')"
if: steps.changesets.outputs.published == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ env.CURRENT_PACKAGE_VERSION }}

release-unstable:
runs-on: ubuntu-20.04
name: Release Unstable
if: "always() && github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'chore(release): new version')"
needs: release-stable
if: always() && github.event_name == 'push' && needs.release-stable.outputs.published == 'false'
steps:
- name: Checkout Repo
uses: actions/checkout@v4
Expand Down

0 comments on commit d45598d

Please sign in to comment.