Skip to content

Commit a1e339f

Browse files
ci: update workflows
1 parent 3cb2730 commit a1e339f

7 files changed

Lines changed: 398 additions & 15 deletions

File tree

.github/workflows/commits.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Commits
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
lint:
8+
name: Lint
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Set up Node.js
18+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
19+
with:
20+
node-version: 'lts/*'
21+
cache: 'npm'
22+
23+
- name: Install dependencies
24+
run: npm ci
25+
26+
- name: Check Commitlint (pull request)
27+
if: github.event_name == 'pull_request'
28+
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
29+
30+
- name: Check Commitlint (push)
31+
if: github.event_name == 'push'
32+
run: npx commitlint --last --verbose

.github/workflows/publish.yml

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,25 @@ name: Publish
33
on:
44
workflow_call:
55
inputs:
6+
enable-rust:
7+
description: 'Enable Rust job.'
8+
type: boolean
9+
required: true
10+
enable-typescript:
11+
description: 'Enable TypeScript job.'
12+
type: boolean
13+
required: true
14+
typescript-registry-github:
15+
description: 'Publish TypeScript packages to GitHub Packages registry.'
16+
type: boolean
17+
required: false
18+
default: false
19+
typescript-registry-npm:
20+
description: 'Publish TypeScript packages to npm registry.'
21+
type: boolean
22+
required: false
23+
default: false
24+
625
# Inputs for `actions-rust-lang/setup-rust-toolchain`.
726
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml
827
toolchain:
@@ -19,9 +38,14 @@ permissions:
1938
id-token: write
2039

2140
jobs:
22-
publish:
23-
name: Publish
41+
rust:
42+
name: Rust
2443
runs-on: ubuntu-latest
44+
if: ${{ inputs.enable-rust }}
45+
46+
permissions:
47+
contents: read
48+
id-token: write
2549

2650
steps:
2751
- name: Checkout
@@ -46,3 +70,48 @@ jobs:
4670
run: cargo workspaces publish --publish-as-is
4771
env:
4872
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
73+
74+
typescript:
75+
name: TypeScript
76+
runs-on: ubuntu-latest
77+
if: ${{ inputs.enable-typescript }}
78+
79+
permissions:
80+
contents: read
81+
id-token: write
82+
packages: write
83+
84+
steps:
85+
- name: Checkout
86+
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
87+
88+
- name: Set up Node.js
89+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
90+
with:
91+
node-version: 'lts/*'
92+
cache: 'npm'
93+
registry-url: 'https://registry.npmjs.org'
94+
95+
- name: Install dependencies
96+
run: npm ci
97+
98+
- name: Build
99+
run: npm run build
100+
101+
- name: Publish to npm
102+
if: ${{ inputs.typescript-registry-npm }}
103+
run: npm publish --access public --registry https://registry.npmjs.org --workspaces
104+
105+
- name: Set up Node.js
106+
if: ${{ inputs.typescript-registry-github }}
107+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
108+
with:
109+
node-version: 'lts/*'
110+
cache: 'npm'
111+
registry-url: 'https://npm.pkg.github.com'
112+
113+
- name: Publish to GitHub Packages
114+
if: ${{ inputs.typescript-registry-github }}
115+
run: npm publish --access public --registry https://npm.pkg.github.com --workspaces
116+
env:
117+
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pull-request.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Pull Request
2+
3+
on:
4+
workflow_call:
5+
6+
permissions:
7+
contents: read
8+
9+
jobs:
10+
title:
11+
name: Title
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Conventional Commits
16+
uses: ytanikin/pr-conventional-commits@639145d78959c53c43112365837e3abd21ed67c1 # 1.5.2
17+
with:
18+
task_types: '["build","chore","ci","docs","feat","fix","perf","refactor","revert","style","test"]'
19+
add_label: 'false'

.github/workflows/release-self.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Release Self
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
bump:
7+
description: 'Bump version by semver keyword.'
8+
required: true
9+
type: choice
10+
options:
11+
- patch
12+
- minor
13+
- major
14+
15+
permissions:
16+
contents: write
17+
18+
jobs:
19+
release:
20+
name: Release
21+
uses: ./.github/workflows/release.yml
22+
with:
23+
bump: ${{ inputs.bump }}
24+
bump-rust: false
25+
bump-typescript: true
26+
bump-typescript-tool: 'npm'
27+
extract-version: 'typescript'
28+
secrets:
29+
app-client-id: ${{ secrets.APP_ID }}
30+
app-private-key: ${{ secrets.APP_PRIVATE_KEY }}

.github/workflows/release.yml

Lines changed: 76 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,25 @@ on:
55
inputs:
66
bump:
77
description: 'Bump version by semver keyword.'
8+
type: string
9+
required: true
10+
bump-rust:
11+
description: 'Bump Rust version.'
12+
type: boolean
13+
required: true
14+
bump-typescript:
15+
description: 'Bump TypeScript version.'
16+
type: boolean
817
required: true
18+
bump-typescript-tool:
19+
description: 'TypeScript tool to use for bumping (`lerna` or `npm`).'
20+
type: string
21+
required: false
22+
default: 'lerna'
23+
extract-version:
24+
description: 'Version to extract (`rust` or `typescript`).'
925
type: string
26+
required: true
1027

1128
# Inputs for `actions-rust-lang/setup-rust-toolchain`.
1229
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml
@@ -18,6 +35,13 @@ on:
1835
description: 'Target triple to install for this toolchain'
1936
type: string
2037
required: false
38+
secrets:
39+
app-client-id:
40+
description: 'GitHub App Client ID.'
41+
required: true
42+
app-private-key:
43+
description: 'GitHub App private key.'
44+
required: true
2145

2246
permissions:
2347
contents: write
@@ -32,39 +56,83 @@ jobs:
3256
id: app-token
3357
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
3458
with:
35-
client-id: ${{ secrets.APP_ID }}
36-
private-key: ${{ secrets.APP_PRIVATE_KEY }}
59+
client-id: ${{ secrets.app-client-id }}
60+
private-key: ${{ secrets.app-private-key }}
3761

3862
- name: Checkout
3963
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
4064

4165
- name: Set up Rust toolchain
66+
if: ${{ inputs.bump-rust }}
4267
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
4368
with:
4469
toolchain: ${{ inputs.toolchain }}
4570
target: ${{ inputs.target }}
4671

4772
- name: Install Cargo Binary Install
73+
if: ${{ inputs.bump-rust }}
4874
uses: cargo-bins/cargo-binstall@aaa84a43aec4955a42c5ffc65d258961e39f276e # v1.19.1
4975

5076
- name: Install crates
77+
if: ${{ inputs.bump-rust }}
5178
run: cargo binstall --force -y cargo-workspaces toml-cli
5279

53-
- name: Bump version
80+
- name: Bump Rust version
81+
if: ${{ inputs.bump-rust }}
5482
run: cargo workspaces version --all --no-git-commit --yes ${{ inputs.bump }}
5583

56-
- name: Extract version
57-
id: extract-version
84+
- name: Extract Rust version
85+
if: ${{ inputs.extract-version == 'rust' }}
86+
id: extract-rust-version
5887
run: echo "VERSION=v$(toml get Cargo.toml workspace.package.version --raw)" >> "$GITHUB_OUTPUT"
5988

89+
- name: Set up Node.js
90+
if: ${{ inputs.bump-typescript }}
91+
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
92+
with:
93+
node-version: 'lts/*'
94+
cache: 'npm'
95+
96+
- name: Install dependencies
97+
if: ${{ inputs.bump-typescript }}
98+
run: npm ci
99+
100+
- name: Bump TypeScript version
101+
if: ${{ inputs.bump-typescript }}
102+
env:
103+
TOOL: ${{ case(inputs.bump-typescript-tool == 'lerna', 'npx lerna', 'npm') }}
104+
run: $TOOL version --no-git-tag-version --yes ${{ inputs.bump }}
105+
106+
- name: Extract TypeScript version
107+
if: ${{ inputs.extract-version == 'typescript' }}
108+
id: extract-typescript-version
109+
env:
110+
FILE: ${{ case(inputs.bump-typescript-tool == 'lerna', 'lerna', 'package') }}
111+
run: echo "VERSION=v$(jq -r .version ./$FILE.json)" >> "$GITHUB_OUTPUT"
112+
113+
- name: Format with Prettier
114+
if: ${{ inputs.extract-version == 'typescript' }}
115+
run: npx prettier --write .
116+
117+
- name: Version
118+
id: version
119+
env:
120+
VERSION: |-
121+
${{ case(
122+
inputs.extract-version == 'rust', steps.extract-rust-version.outputs.VERSION,
123+
inputs.extract-version == 'typescript', steps.extract-typescript-version.outputs.VERSION,
124+
''
125+
) }}
126+
run: test -n "$VERSION" && echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
127+
60128
- name: Add changes
61129
run: git add .
62130

63131
- name: Commit
64132
id: commit
65133
uses: dsanders11/github-app-commit-action@2bbcd331016d8c950b05a24b56e7eb9cb50d545e # v2.1.0
66134
with:
67-
message: ${{ steps.extract-version.outputs.VERSION }}
135+
message: ${{ steps.version.outputs.VERSION }}
68136
token: ${{ steps.app-token.outputs.token }}
69137

70138
- name: Reset and pull
@@ -73,7 +141,7 @@ jobs:
73141
- name: Tag
74142
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
75143
env:
76-
GIT_TAG: ${{ steps.extract-version.outputs.VERSION }}
144+
GIT_TAG: ${{ steps.version.outputs.VERSION }}
77145
GIT_SHA: ${{ steps.commit.outputs.sha }}
78146
with:
79147
script: |
@@ -89,5 +157,5 @@ jobs:
89157
with:
90158
generate_release_notes: true
91159
make_latest: true
92-
tag_name: ${{ steps.extract-version.outputs.VERSION }}
160+
tag_name: ${{ steps.version.outputs.VERSION }}
93161
token: ${{ steps.app-token.outputs.token }}

0 commit comments

Comments
 (0)