Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
refactor: use changelogen instead of changelogithub
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolassutter committed Nov 29, 2023
1 parent af48e86 commit e211e12
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 93 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: Release
on:
push:
tags:
- "v*"
- "!v*-beta*"
- 'v*'
- '!v*-beta*'

jobs:
release:
Expand All @@ -27,15 +27,20 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
registry-url: "https://registry.npmjs.org"
registry-url: 'https://registry.npmjs.org'

- name: Install deps
run: pnpm install

- name: Builds
run: pnpm build

- run: pnpm changelogithub
- run: pnpm changelogen

- name: Echo tag name
run: echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV

- run: pnpm changelogen gh release ${{ env.TAG_NAME }}
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}

Expand Down
Empty file added CHANGELOG.md
Empty file.
6 changes: 3 additions & 3 deletions changelogithub.config.ts → changelog.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { defineConfig } from 'changelogithub'
import { ChangelogConfig } from 'changelogen'
import { execaCommandSync } from 'execa'
import { readPackageSync } from 'read-pkg'

Expand Down Expand Up @@ -28,10 +28,10 @@ if (!from) {
throw new Error('Unable to find previous release.')
}

export default defineConfig({
export default {
/**
* When pushing a new main release, the `from` should be the last main release tag (and not a beta version)
* When pushing a new beta release, the `from` should be the last release (beta or main)
*/
from,
})
} satisfies Partial<ChangelogConfig>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"@types/node": "^20.8.4",
"@types/prettier": "^2.7.3",
"bumpp": "^9.2.0",
"changelogithub": "^0.13.1",
"changelogen": "^0.5.5",
"eslint": "^8.54.0",
"husky": "^8.0.3",
"read-pkg": "^8.1.0",
Expand Down
153 changes: 78 additions & 75 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 4 additions & 10 deletions scripts/slack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,13 @@ async function start() {

const { version, name: pkgName } = await readPackage()

const contentRegexp = /----+\n\n(?<content>(?:.|\s)*)\n\n----+/m

let { stdout: changelog } = await execaCommand('pnpm changelogithub --dry')
let { stdout: changelog } = await execaCommand(
'pnpm changelogen --no-output',
)

changelog = stripAnsi(changelog)

const releaseContent = changelog.match(contentRegexp)?.groups?.content

if (!releaseContent) {
throw new Error('`releaseContent` does not contain text.')
}

const text = releaseContent
const text = changelog
.trim()
// Gestion du gras pour Slack
.replace(/\*\*/gm, '*')
Expand Down

0 comments on commit e211e12

Please sign in to comment.