Skip to content

Commit

Permalink
ci(repo): improve/fix release action (#14)
Browse files Browse the repository at this point in the history
* ci: improve/fix release action

Now, on each push on master, a new stable release is made following
semver using commit logs with Knope

* ci: better commitlint config

* ci: adjust rust toolchain install

* ci: add wasm target
  • Loading branch information
pedronauck committed Jun 11, 2024
1 parent a97be4b commit d9824f2
Show file tree
Hide file tree
Showing 26 changed files with 1,099 additions and 507 deletions.
Empty file added .changeset/.gitkeep
Empty file.
File renamed without changes.
7 changes: 7 additions & 0 deletions .commitlintrc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends: ['@commitlint/config-conventional']

rules:
type-enum:
- 2
- always
- [arch, build, ci, docs, feat, fix, perf, refactor, test]
7 changes: 0 additions & 7 deletions .cz.toml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/actions/setup-node/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Setup Node & PNPM
description: Install NodeJS and PNPM tooling

runs:
using: composite
steps:
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: 20

- uses: pnpm/action-setup@v4
name: Install pnpm
with:
version: 9
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v4
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |-
${{ runner.os }}-pnpm-store-
43 changes: 43 additions & 0 deletions .github/actions/setup-rust/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Setup Rust
description: Install Rust tooling with Cache

inputs:
target:
description: Rust target platforms
required: false
default: x86_64-unknown-linux-gnu
toolchain:
description: Rust toolchain version to install
required: true
default: stable

runs:
using: composite
steps:
- name: Install Rust
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ inputs.toolchain }}
target: ${{ inputs.target }}
components: clippy, rustfmt

- name: Cache Rust toolchain
uses: actions/cache@v4
with:
path: |
~/.rustup
~/.cargo/bin
key: ${{ runner.os }}-rust-${{ inputs.toolchain }}-${{ inputs.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-rust-${{ inputs.toolchain }}-${{ inputs.target }}-
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-rust-target-${{ inputs.toolchain }}-${{ inputs.target }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |-
${{ runner.os }}-rust-target-${{ inputs.toolchain }}-${{ inputs.target }}-
87 changes: 63 additions & 24 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
name: CI

permissions:
contents: read

on:
pull_request:
types: [opened, synchronize, edited, closed, reopened]
types: [opened, synchronize, edited, reopened]

env:
CARGO_TERM_COLOR: always
Expand All @@ -17,47 +14,89 @@ concurrency:
cancel-in-progress: true

jobs:
validate-itle:
validate-title:
name: Validate PR Title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v4
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
requireScope: true
types: |
arch
build
ci
docs
feat
fix
perf
refactor
test
scopes: |
repo
release
data-stream
sdk-rust
sdk-ts
lockfile:
name: Validate Lockfile
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
uses: ./.github/actions/setup-rust
with:
toolchain: stable
target: wasm32-unknown-unknown

- uses: Swatinem/rust-cache@v2
- name: Is lockfile updated?
run: cargo update --workspace --locked
- run: cargo update --workspace --locked

clippy:
name: Clippy
commitlint:
name: Validating commits
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ env.RUST_VERSION }}
targets: wasm32-unknown-unknown
components: clippy
- uses: Swatinem/rust-cache@v2
- run: cargo clippy --all-targets --all-features
fetch-depth: 0

- name: Setup Node && PNPM
uses: ./.github/actions/setup-node

- name: Install commitlint
run: |
npm install @commitlint/config-conventional
pre-commit:
name: Linting & Formatting
permissions:
contents: read
- name: Validate current commit (last commit) with commitlint
if: github.event_name == 'push'
run: npx commitlint --last --verbose

- name: Validate PR commits with commitlint
if: github.event_name == 'pull_request'
run: |
npx commitlint \
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} \
--to ${{ github.event.pull_request.head.sha }} \
--verbose
lint:
name: Linting
if: "!startsWith(github.head_ref, 'releases/')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
- name: Install Rust
uses: ./.github/actions/setup-rust
with:
toolchain: nightly
target: wasm32-unknown-unknown

- name: Install dependencies
uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-sort@1.0.9

- name: Running linting
run: make lint
68 changes: 68 additions & 0 deletions .github/workflows/prepare_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Open Release PR

on:
push:
branches: [main, staging, release]

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
CARGO_TERM_COLOR: always
CLICOLOR: 1
RUST_VERSION: 1.78.0

jobs:
setup:
if: "!startsWith(github.event.head_commit.message, 'ci(release)')"
runs-on: ubuntu-latest
outputs:
branch: ${{ steps.set-vars.outputs.branch }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Check for pre-release configuration
id: set-vars
run: |
echo "branch=changeset/release-main" >> $GITHUB_OUTPUT
prepare-release:
if: "!startsWith(github.event.head_commit.message, 'ci(release)')"
needs: setup
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.REPO_TOKEN }}

- name: Configure Git
run: |
git config --global user.name GitHub Actions
git config user.email github-actions@github.com
- name: Install Rust
uses: ./.github/actions/setup-rust
with:
toolchain: nightly

- uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-sort@1.0.9

- uses: taiki-e/cache-cargo-install-action@v2
with:
tool: cargo-edit@0.12.3

- uses: knope-dev/action@v2.1.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Run knope prepare release
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
RELEASE_BRANCH: ${{ needs.setup.outputs.branch }}
run: knope prepare-release --verbose
Loading

0 comments on commit d9824f2

Please sign in to comment.