Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
32 changes: 32 additions & 0 deletions .github/workflows/commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Commits

on:
workflow_call:

jobs:
lint:
name: Lint
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 'lts/*'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Check Commitlint (pull request)
if: github.event_name == 'pull_request'
run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose

- name: Check Commitlint (push)
if: github.event_name == 'push'
run: npx commitlint --last --verbose
73 changes: 71 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,25 @@ name: Publish
on:
workflow_call:
inputs:
enable-rust:
description: 'Enable Rust job.'
type: boolean
required: true
enable-typescript:
description: 'Enable TypeScript job.'
type: boolean
required: true
typescript-registry-github:
description: 'Publish TypeScript packages to GitHub Packages registry.'
type: boolean
required: false
default: false
typescript-registry-npm:
description: 'Publish TypeScript packages to npm registry.'
type: boolean
required: false
default: false

# Inputs for `actions-rust-lang/setup-rust-toolchain`.
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml
toolchain:
Expand All @@ -19,9 +38,14 @@ permissions:
id-token: write

jobs:
publish:
name: Publish
rust:
name: Rust
runs-on: ubuntu-latest
if: ${{ inputs.enable-rust }}

permissions:
contents: read
id-token: write

steps:
- name: Checkout
Expand All @@ -46,3 +70,48 @@ jobs:
run: cargo workspaces publish --publish-as-is
env:
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

typescript:
name: TypeScript
runs-on: ubuntu-latest
if: ${{ inputs.enable-typescript }}

permissions:
contents: read
id-token: write
packages: write

steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 'lts/*'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Publish to npm
if: ${{ inputs.typescript-registry-npm }}
run: npm publish --access public --registry https://registry.npmjs.org --workspaces

- name: Set up Node.js
if: ${{ inputs.typescript-registry-github }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 'lts/*'
cache: 'npm'
registry-url: 'https://npm.pkg.github.com'

- name: Publish to GitHub Packages
if: ${{ inputs.typescript-registry-github }}
run: npm publish --access public --registry https://npm.pkg.github.com --workspaces
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Pull Request

on:
workflow_call:

permissions:
contents: read

jobs:
title:
name: Title
runs-on: ubuntu-latest

steps:
- name: Conventional Commits
uses: ytanikin/pr-conventional-commits@639145d78959c53c43112365837e3abd21ed67c1 # 1.5.2
with:
task_types: '["build","chore","ci","docs","feat","fix","perf","refactor","revert","style","test"]'
add_label: 'false'
30 changes: 30 additions & 0 deletions .github/workflows/release-self.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Release Self

on:
workflow_dispatch:
inputs:
bump:
description: 'Bump version by semver keyword.'
required: true
type: choice
options:
- patch
- minor
- major

permissions:
contents: write

jobs:
release:
name: Release
uses: ./.github/workflows/release.yml
with:
bump: ${{ inputs.bump }}
bump-rust: false
bump-typescript: true
bump-typescript-tool: 'npm'
extract-version: 'typescript'
secrets:
app-client-id: ${{ secrets.APP_ID }}
app-private-key: ${{ secrets.APP_PRIVATE_KEY }}
84 changes: 76 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,25 @@ on:
inputs:
bump:
description: 'Bump version by semver keyword.'
type: string
required: true
bump-rust:
description: 'Bump Rust version.'
type: boolean
required: true
bump-typescript:
description: 'Bump TypeScript version.'
type: boolean
required: true
bump-typescript-tool:
description: 'TypeScript tool to use for bumping (`lerna` or `npm`).'
type: string
required: false
default: 'lerna'
extract-version:
description: 'Version to extract (`rust` or `typescript`).'
type: string
required: true

# Inputs for `actions-rust-lang/setup-rust-toolchain`.
# https://github.com/actions-rust-lang/setup-rust-toolchain/blob/main/action.yml
Expand All @@ -18,6 +35,13 @@ on:
description: 'Target triple to install for this toolchain'
type: string
required: false
secrets:
app-client-id:
description: 'GitHub App Client ID.'
required: true
app-private-key:
description: 'GitHub App private key.'
required: true

permissions:
contents: write
Expand All @@ -32,39 +56,83 @@ jobs:
id: app-token
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
with:
client-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
client-id: ${{ secrets.app-client-id }}
private-key: ${{ secrets.app-private-key }}

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

- name: Set up Rust toolchain
if: ${{ inputs.bump-rust }}
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1.16.1
with:
toolchain: ${{ inputs.toolchain }}
target: ${{ inputs.target }}

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

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

- name: Bump version
- name: Bump Rust version
if: ${{ inputs.bump-rust }}
run: cargo workspaces version --all --no-git-commit --yes ${{ inputs.bump }}

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

- name: Set up Node.js
if: ${{ inputs.bump-typescript }}
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: 'lts/*'
cache: 'npm'

- name: Install dependencies
if: ${{ inputs.bump-typescript }}
run: npm ci

- name: Bump TypeScript version
if: ${{ inputs.bump-typescript }}
env:
TOOL: ${{ case(inputs.bump-typescript-tool == 'lerna', 'npx lerna', 'npm') }}
run: $TOOL version --no-git-tag-version --yes ${{ inputs.bump }}

- name: Extract TypeScript version
if: ${{ inputs.extract-version == 'typescript' }}
id: extract-typescript-version
env:
FILE: ${{ case(inputs.bump-typescript-tool == 'lerna', 'lerna', 'package') }}
run: echo "VERSION=v$(jq -r .version ./$FILE.json)" >> "$GITHUB_OUTPUT"

- name: Format with Prettier
if: ${{ inputs.extract-version == 'typescript' }}
run: npx prettier --write .

- name: Version
id: version
env:
VERSION: |-
${{ case(
inputs.extract-version == 'rust', steps.extract-rust-version.outputs.VERSION,
inputs.extract-version == 'typescript', steps.extract-typescript-version.outputs.VERSION,
''
) }}
run: test -n "$VERSION" && echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"

- name: Add changes
run: git add .

- name: Commit
id: commit
uses: dsanders11/github-app-commit-action@2bbcd331016d8c950b05a24b56e7eb9cb50d545e # v2.1.0
with:
message: ${{ steps.extract-version.outputs.VERSION }}
message: ${{ steps.version.outputs.VERSION }}
token: ${{ steps.app-token.outputs.token }}

- name: Reset and pull
Expand All @@ -73,7 +141,7 @@ jobs:
- name: Tag
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
env:
GIT_TAG: ${{ steps.extract-version.outputs.VERSION }}
GIT_TAG: ${{ steps.version.outputs.VERSION }}
GIT_SHA: ${{ steps.commit.outputs.sha }}
with:
script: |
Expand All @@ -89,5 +157,5 @@ jobs:
with:
generate_release_notes: true
make_latest: true
tag_name: ${{ steps.extract-version.outputs.VERSION }}
tag_name: ${{ steps.version.outputs.VERSION }}
token: ${{ steps.app-token.outputs.token }}
Loading