Skip to content

Commit fc4c4bd

Browse files
ci: updates (#795)
1 parent fba6c3f commit fc4c4bd

10 files changed

Lines changed: 142 additions & 160 deletions

File tree

.github/actions/protect-main/action.yml

Lines changed: 0 additions & 58 deletions
This file was deleted.

.github/actions/unprotect-main/action.yml

Lines changed: 0 additions & 24 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ jobs:
88
node-version: ${{ matrix.node_version }}
99
- run: pnpm build
1010
- run: node ./lib/index.mjs
11+
- run: pnpm run lint:package
1112

1213
strategy:
1314
fail-fast: false

.github/workflows/release-pr.yml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
concurrency:
2+
cancel-in-progress: true
3+
group: Prepare Release ${{ github.ref_name }}
4+
5+
jobs:
6+
release_pr:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
fetch-depth: 0
12+
13+
- uses: ./.github/actions/prepare
14+
15+
- run: pnpm build
16+
17+
- id: should_release
18+
run: echo "should_release=$(pnpm run should-semantic-release && pnpm run lint:package &> /dev/null && echo '1' || echo '0')" >> "$GITHUB_OUTPUT"
19+
20+
- env:
21+
GITHUB_TOKEN: ${{ github.token }}
22+
if: steps.should_release.outputs.should_release != '0'
23+
run: pnpm dlx release-it --no-git.push --no-npm.publish --no-github.release --no-gitlab.release
24+
25+
- if: steps.should_release.outputs.should_release != '0'
26+
name: Generate Docs
27+
run: pnpm run docs
28+
29+
- if: steps.should_release.outputs.should_release != '0'
30+
name: Create a pages artifact
31+
uses: actions/upload-pages-artifact@v3
32+
with:
33+
path: ./docs/generated
34+
35+
- if: steps.should_release.outputs.should_release != '0'
36+
name: Deploy to GitHub Pages
37+
uses: actions/deploy-pages@v2
38+
39+
- if: steps.should_release.outputs.should_release != '0'
40+
name: Update Coverage Badge
41+
run: cp ./docs/generated/coverage.svg ./docs/coverage.svg
42+
43+
- id: package-version
44+
if: steps.should_release.outputs.should_release != '0'
45+
name: Get Release Version
46+
uses: martinbeentjes/npm-get-version-action@v1.3.1
47+
48+
- env:
49+
RELEASE_VERSION: ${{ steps.package-version.outputs.current-version }}
50+
if: steps.should_release.outputs.should_release != '0' && steps.package-version.outputs.current-version != ''
51+
name: Create Pull Request
52+
uses: peter-evans/create-pull-request@v8.1.0
53+
with:
54+
assignees: ${{ github.actor }}
55+
base: ${{ github.ref_name }}
56+
body: Merge this PR to release v${{ env.RELEASE_VERSION }}
57+
branch: release/${{ github.ref_name }}
58+
commit-message: "chore: release v${{ env.RELEASE_VERSION }}"
59+
delete-branch: true
60+
sign-commits: true
61+
title: Release v${{ env.RELEASE_VERSION }}
62+
token: ${{ github.token }}
63+
64+
name: Create Release PR
65+
66+
on:
67+
push:
68+
branches:
69+
- main
70+
71+
permissions:
72+
contents: write
73+
pull-requests: write

.github/workflows/release.yml

Lines changed: 21 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,36 @@ concurrency:
44

55
jobs:
66
release:
7-
outputs:
8-
did_release: ${{ steps.should_release.outputs.should_release }}
7+
if: "startsWith(github.event.head_commit.message, 'chore: release v')"
98
runs-on: ubuntu-latest
109
steps:
11-
- uses: actions/checkout@v4
10+
- uses: actions/checkout@v6
1211
with:
1312
fetch-depth: 0
14-
- uses: ./.github/actions/prepare
15-
- run: pnpm build
1613

17-
- id: should_release
18-
run: echo "should_release=$(pnpm run should-semantic-release &> /dev/null && echo '1' || echo '0')" >> "$GITHUB_OUTPUT"
19-
20-
- if: steps.should_release.outputs.should_release != '0'
21-
uses: ./.github/actions/unprotect-main
22-
with:
23-
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
24-
- env:
25-
GITHUB_TOKEN: ${{ github.token }}
26-
if: steps.should_release.outputs.should_release != '0'
27-
run: pnpm release-it --verbose
28-
29-
- if: steps.should_release.outputs.should_release != '0'
30-
name: Generate Docs
31-
run: pnpm run docs
32-
33-
- if: steps.should_release.outputs.should_release != '0'
34-
name: Create a pages artifact
35-
uses: actions/upload-pages-artifact@v3
14+
- id: regex-match
15+
uses: kaisugi/action-regex-match@v1.0.2
3616
with:
37-
path: ./docs/generated
17+
flags: "su"
18+
regex: '^chore: release v(\d+\.\d+\.\d+(?:-(?:alpha|beta|rc)\.\d+)?)(?: \(#\d+\))?(?:\n|$)'
19+
text: ${{ github.event.head_commit.message }}
3820

39-
- id: deployment
40-
if: steps.should_release.outputs.should_release != '0'
41-
name: Deploy to GitHub Pages
42-
uses: actions/deploy-pages@v2
21+
- id: release_version
22+
if: steps.regex-match.outputs.match != ''
23+
run: echo "release_version=${{ steps.regex-match.outputs.group1 }}" >> "$GITHUB_OUTPUT"
4324

44-
- if: steps.should_release.outputs.should_release != '0'
45-
name: Update Coverage Badge
46-
run: cp ./docs/generated/coverage.svg ./docs/coverage.svg
25+
- if: steps.release_version.outputs.release_version != ''
26+
uses: ./.github/actions/prepare
4727

48-
- id: coverage_changed
49-
if: steps.should_release.outputs.should_release != '0'
50-
run: echo "coverage_changed=$(git status --porcelain -u | grep -c docs/coverage.svg)" >> "$GITHUB_OUTPUT"
28+
- if: steps.release_version.outputs.release_version != ''
29+
name: Build
30+
run: pnpm run build
5131

5232
- env:
53-
COVERAGE_CHANGED: ${{ steps.coverage_changed.outputs.coverage_changed }}
54-
id: push_coverage
55-
if: steps.should_release.outputs.should_release != '0'
56-
run: echo "push_coverage=$(if [[ "$COVERAGE_CHANGED" != '0' ]] ; then echo '1' ; else echo '0' ; fi)" >> "$GITHUB_OUTPUT"
57-
58-
- if: steps.should_release.outputs.should_release != '0' && steps.push_coverage.outputs.push_coverage != '0'
59-
uses: ./.github/actions/unprotect-main
60-
with:
61-
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
62-
63-
- if: steps.should_release.outputs.should_release != '0' && steps.push_coverage.outputs.push_coverage != '0'
64-
run: |
65-
git add docs/coverage.svg
66-
git commit -m "docs: update documentation coverage badge"
67-
git push
68-
69-
- continue-on-error: true
70-
if: always() && steps.should_release.outputs.should_release != '0'
71-
uses: ./.github/actions/protect-main
72-
with:
73-
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
33+
GITHUB_TOKEN: ${{ github.token }}
34+
if: steps.release_version.outputs.release_version != ''
35+
name: Release
36+
run: pnpm dlx release-it --npm.allowSameVersion -i ${{ steps.release_version.outputs.release_version }}
7437

7538
name: Release
7639

@@ -82,3 +45,5 @@ on:
8245
permissions:
8346
contents: write
8447
id-token: write
48+
issues: write
49+
pull-requests: write

.github/workflows/resync-protection.yml

Lines changed: 0 additions & 18 deletions
This file was deleted.

.release-it.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"git": {
3-
"commitMessage": "chore: release v${version}",
4-
"requireCommits": true
3+
"commit": false
54
},
65
"github": {
76
"autoGenerate": true,

cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"outro",
2828
"packagejson",
2929
"phenomnomnominal",
30+
"publint",
3031
"quickstart",
3132
"tseslint",
3233
"tsquery",

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
"lint:docs": "typedoc --validation --treatValidationWarningsAsErrors",
3535
"lint:knip": "knip",
3636
"lint:md": "markdownlint \"**/*.md\" \".github/**/*.md\" --rules sentences-per-line",
37+
"lint:package": "publint --strict",
3738
"lint:packages": "pnpm dedupe --check",
3839
"lint:spelling": "cspell \"**\" \".github/**/*\"",
3940
"prepare": "husky",
@@ -74,6 +75,7 @@
7475
"prettier": "^3.4.2",
7576
"prettier-plugin-curly": "^0.3.1",
7677
"prettier-plugin-packagejson": "^2.5.8",
78+
"publint": "^0.3.17",
7779
"release-it": "^18.1.2",
7880
"sentences-per-line": "^0.3.0",
7981
"should-semantic-release": "^0.3.0",

0 commit comments

Comments
 (0)