Skip to content

Commit b43ac44

Browse files
bluwyAndarist
andauthored
Sync ci and publish workflows (#86)
* Sync ci and publish workflows * Format * Apply suggestions from code review Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com> --------- Co-authored-by: Mateusz Burzyński <mateuszburzynski@gmail.com>
1 parent b573319 commit b43ac44

4 files changed

Lines changed: 68 additions & 37 deletions

File tree

.github/workflows/ci.yml

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
merge_group:
88
branches:
99
- main
10+
- next
11+
# merge group rulesets don't allow wildcards so in settings each maintenance branch needs to be added separately
12+
- "maintenance/v*" # branch rulesets don't support v[0-9]+
1013

1114
permissions:
1215
contents: read
@@ -16,39 +19,24 @@ concurrency:
1619
cancel-in-progress: true
1720

1821
jobs:
19-
build:
20-
name: Build
22+
lint-workflows:
23+
name: Lint workflows
2124
runs-on: ubuntu-latest
25+
permissions:
26+
actions: read # only required in private repos
27+
security-events: write # allow writing security events
2228
steps:
2329
- name: Check out repo
2430
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
2531
with:
2632
persist-credentials: false
2733

28-
- uses: ./.github/actions/ci-setup
29-
30-
- name: Build
31-
run: pnpm build
32-
33-
lint:
34-
name: Lint
35-
runs-on: ubuntu-latest
36-
steps:
37-
- name: Check out repo
38-
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
34+
- name: Run zizmor
35+
uses: zizmorcore/zizmor-action@5f14fd08f7cf1cb1609c1e344975f152c7ee938d # v0.5.6
3936
with:
40-
persist-credentials: false
41-
42-
- uses: ./.github/actions/ci-setup
43-
44-
- name: Codegen
45-
run: pnpm codegen:github
46-
47-
- name: Lint
48-
run: pnpm lint
49-
50-
- name: Format
51-
run: pnpm format
37+
persona: pedantic
38+
annotations: true
39+
advanced-security: false
5240

5341
test:
5442
name: Test
@@ -81,12 +69,49 @@ jobs:
8169
env:
8270
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8371

72+
typecheck:
73+
name: Typecheck
74+
runs-on: ubuntu-latest
75+
timeout-minutes: 20
76+
steps:
77+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
78+
with:
79+
persist-credentials: false
80+
81+
- uses: ./.github/actions/ci-setup
82+
83+
- name: Codegen
84+
run: pnpm codegen:github
85+
86+
- name: Typecheck
87+
run: pnpm typecheck
88+
89+
lint:
90+
name: Lint
91+
runs-on: ubuntu-latest
92+
timeout-minutes: 20
93+
steps:
94+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
95+
with:
96+
persist-credentials: false
97+
98+
- uses: ./.github/actions/ci-setup
99+
100+
- name: Codegen
101+
run: pnpm codegen:github
102+
103+
- name: Lint
104+
run: pnpm lint
105+
106+
- name: Format
107+
run: pnpm format
108+
84109
ci-ok:
85110
name: CI OK
86111
runs-on: ubuntu-latest
87112
if: always()
88-
needs: [build, lint, test]
113+
needs: [lint-workflows, test, typecheck, lint]
89114
steps:
90115
- name: Exit with error if some jobs are not successful
91-
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}
92116
run: exit 1
117+
if: ${{ always() && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }}

.github/workflows/publish.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ on:
44
push:
55
branches:
66
- main
7+
- next
8+
- "maintenance/v*" # branch rulesets don't support v[0-9]+
79

810
concurrency:
911
group: ${{ github.workflow }}-${{ github.ref }}
1012
cancel-in-progress: false
1113
queue: max
1214

13-
permissions: {}
15+
permissions: {} # each job should define its own permission explicitly
1416

1517
jobs:
1618
version:
@@ -21,8 +23,7 @@ jobs:
2123
outputs:
2224
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }}
2325
permissions:
24-
contents: write # to create version commits (changesets/action)
25-
pull-requests: write # to create pull request (changesets/action)
26+
contents: read # to check out repo (actions/checkout)
2627
steps:
2728
- name: Check out repo
2829
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
@@ -33,11 +34,13 @@ jobs:
3334
with:
3435
skip-cache: true # avoid cache poisoning attacks
3536

36-
- uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3.1.1
37+
- uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
3738
id: app-token
3839
with:
3940
client-id: ${{ vars.APP_CLIENT_ID }}
4041
private-key: ${{ secrets.APP_PRIVATE_KEY }}
42+
permission-contents: write # to create version commits (changesets/action)
43+
permission-pull-requests: write # to create pull request (changesets/action)
4144

4245
- name: Create or update release pull request
4346
id: changesets
@@ -66,11 +69,8 @@ jobs:
6669
with:
6770
skip-cache: true # avoid cache poisoning attacks
6871

69-
- name: Build
70-
run: pnpm build
71-
7272
- name: Publish to npm
7373
uses: changesets/action@63a615b9cd06ba9a3e6d13796c7fbcb080a60a0b # v1.8.0
7474
with:
75-
publish: pnpm changeset publish
75+
publish: pnpm release
7676
commitMode: github-api

.vscode/settings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"js/ts.tsdk.path": "node_modules/typescript/lib",
3+
"editor.defaultFormatter": "oxc.oxc-vscode"
4+
}

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,15 @@
4848
"access": "public"
4949
},
5050
"scripts": {
51-
"build": "pnpm codegen:github && tsc && tsdown",
51+
"build": "pnpm codegen:github && tsdown",
5252
"codegen:github": "graphql-codegen --config src/github/codegen.ts",
53+
"typecheck": "tsc",
5354
"format": "oxfmt --check",
5455
"format:fix": "oxfmt",
5556
"lint": "oxlint",
5657
"test:integration": "vitest -c vitest.integration.config.ts",
57-
"version-packages": "pnpm changeset version && pnpm format:fix"
58+
"version-packages": "changeset version && pnpm format:fix",
59+
"release": "pnpm build && changeset publish"
5860
},
5961
"dependencies": {
6062
"isomorphic-git": "^1.36.3"

0 commit comments

Comments
 (0)