Skip to content

Commit d45598d

Browse files
authored
ci: fix release with merge commit (#51)
Signed-off-by: Timo Glastra <[email protected]>
1 parent f153eea commit d45598d

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

.changeset/commit.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
const { execSync } = require('node:child_process')
2+
3+
const getSignedOffBy = () => {
4+
const gitUserName = execSync('git config user.name').toString('utf-8').trim()
5+
const gitEmail = execSync('git config user.email').toString('utf-8').trim()
6+
7+
return `Signed-off-by: ${gitUserName} <${gitEmail}>`
8+
}
9+
10+
const getAddMessage = async (changeset) => {
11+
return `docs(changeset): ${changeset.summary}\n\n${getSignedOffBy()}\n`
12+
}
13+
14+
const getVersionMessage = async () => {
15+
return `chore(release): new version\n\n${getSignedOffBy()}\n`
16+
}
17+
18+
module.exports = {
19+
getAddMessage,
20+
getVersionMessage,
21+
}

.changeset/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
33
"changelog": "@changesets/cli/changelog",
4+
"commit": "./commit",
45
"privatePackages": false,
56
"fixed": [["@animo-id/*"]],
67
"access": "public",

.github/workflows/release.yml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ jobs:
1111
release-stable:
1212
runs-on: ubuntu-20.04
1313
name: Release Stable
14+
outputs:
15+
published: ${{ steps.changesets.outputs.published }}
1416
steps:
1517
- name: Checkout Repo
1618
uses: actions/checkout@v4
@@ -25,7 +27,7 @@ jobs:
2527
- name: Install Dependencies
2628
run: pnpm install --frozen-lockfile
2729

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

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

5052
release-unstable:
5153
runs-on: ubuntu-20.04
5254
name: Release Unstable
53-
if: "always() && github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'chore(release): new version')"
55+
needs: release-stable
56+
if: always() && github.event_name == 'push' && needs.release-stable.outputs.published == 'false'
5457
steps:
5558
- name: Checkout Repo
5659
uses: actions/checkout@v4

0 commit comments

Comments
 (0)