From 86d7c45410204cf8e83813166d3565e17cf57e81 Mon Sep 17 00:00:00 2001 From: Art <4998038+Alorel@users.noreply.github.com> Date: Sun, 29 Oct 2023 00:28:36 +0100 Subject: [PATCH] ci: Update automated release workflow --- .github/CODEOWNERS | 1 + .github/CODE_OF_CONDUCT.md | 1 + .github/FUNDING.yml | 6 ++ .github/actions/prep-release/action.yml | 30 ++++++ .github/actions/release/action.yml | 33 ++++++ .github/workflows/core.yml | 129 ++++++++++++++++++++++++ .github/workflows/test.yml | 68 ------------- .gitignore | 1 - 8 files changed, 200 insertions(+), 69 deletions(-) create mode 100644 .github/CODEOWNERS create mode 100644 .github/CODE_OF_CONDUCT.md create mode 100644 .github/FUNDING.yml create mode 100644 .github/actions/prep-release/action.yml create mode 100644 .github/actions/release/action.yml create mode 100644 .github/workflows/core.yml delete mode 100644 .github/workflows/test.yml diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..7252dae --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1 @@ +* @Alorel diff --git a/.github/CODE_OF_CONDUCT.md b/.github/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..edf4995 --- /dev/null +++ b/.github/CODE_OF_CONDUCT.md @@ -0,0 +1 @@ +1. Don't be a cunt :slightly_smiling_face: diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..e0e2e76 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,6 @@ +# These are supported funding model platforms + +github: + - Alorel +custom: + - "https://paypal.me/alorel" diff --git a/.github/actions/prep-release/action.yml b/.github/actions/prep-release/action.yml new file mode 100644 index 0000000..e232ed4 --- /dev/null +++ b/.github/actions/prep-release/action.yml @@ -0,0 +1,30 @@ +name: Prep release +description: Prepare the release +inputs: + release-type: + description: Release type + required: true + version: + description: Next version + required: true +outputs: + in-sync: + description: Sync check + value: ${{ steps.sync-check.outputs.in-sync }} +runs: + using: composite + steps: + - name: Git identity + uses: alorel-actions/git-ident@v1 + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + id: toolchain + with: + cache-prefix: release + - name: cargo-bump + uses: alorel-actions/cargo/bump@v1 + with: + release-type: ${{ inputs.release-type }} + - name: Sync check + id: sync-check + uses: alorel-actions/semantic-release-lite/sync-check@v0 diff --git a/.github/actions/release/action.yml b/.github/actions/release/action.yml new file mode 100644 index 0000000..e09a911 --- /dev/null +++ b/.github/actions/release/action.yml @@ -0,0 +1,33 @@ +name: Release +description: Do the release +inputs: + version: + description: Version to release + required: true + changelog: + description: The changelog + required: true + issues-closed: + description: Issues we've closed + crates-io-token: + description: crates.io API token + required: true +runs: + using: composite + steps: + - uses: alorel-actions/cargo/release-git@v1 + with: + version: ${{ inputs.version }} + changelog: ${{ inputs.changelog }} + + - name: Publish crate + shell: bash + run: cargo publish --locked --token ${{ inputs.crates-io-token }} + + - name: Notify + if: ${{ inputs.issues-closed }} + uses: alorel-actions/semantic-release-lite/notify@v0 + with: + tag: ${{ inputs.version }} + issues: ${{ inputs.issues-closed }} + allow-out-of-sync: true diff --git a/.github/workflows/core.yml b/.github/workflows/core.yml new file mode 100644 index 0000000..5d954d0 --- /dev/null +++ b/.github/workflows/core.yml @@ -0,0 +1,129 @@ +name: Core +on: + push: + branches: [master] + pull_request: {} + +permissions: + contents: read + +env: + CARGO_INCREMENTAL: 0 + RUSTFLAGS: --deny warnings + +jobs: + lint: + name: Lint + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + with: + components: rustfmt,clippy + cache-prefix: lint + local: true + + - name: Fmt + run: cargo fmt --check + + - name: Clippy + run: cargo clippy --locked --tests + + - name: Doc + run: cargo doc --locked --no-deps && rm -rf target/doc + + - name: cargo-rdme + uses: alorel-actions/cargo/rdme@v1 + with: + intralinks-strip-links: true + + test: + name: Test on ${{matrix.toolchain}} + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: + - nightly-2023-10-28 + - stable + - 1.70.0 + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Init toolchain + uses: alorel-actions/cargo/init@v1 + with: + toolchain: ${{matrix.toolchain}} + cache-prefix: test + local: true + + - name: Install wasm-pack + uses: alorel-actions/cargo-global-dep@v1 + with: + name: wasm-pack + version: 0.12.1 + + - name: Test (no features) + run: wasm-pack test --headless --firefox --chrome --locked --no-default-features + + - name: Test (default features) + run: wasm-pack test --headless --firefox --chrome --locked + + - name: Test (nightly) + run: wasm-pack test --headless --firefox --chrome --locked --all-features + if: ${{startsWith(matrix.toolchain, 'nightly')}} + + release: + name: Release + runs-on: ubuntu-latest + if: ${{ github.ref == 'refs/heads/master' }} + needs: + - lint + - test + permissions: + contents: write + steps: + - uses: actions/checkout@v4 + name: Checkout + with: + fetch-depth: 0 + fetch-tags: true + token: ${{ secrets.GH_TOKEN }} + + - name: Parse + id: parse + uses: alorel-actions/semantic-release-lite@v0 + with: + stay-at-zero: true + minor-types: | + feat: Features + patch-types: | + fix: Bug Fixes + trivial-types: | + chore: Maintenance + deps: Dependency updates + ci: CI & Build + build: CI & Build + refactor: Refactors + docs: Documentation + perf: Performance + + - name: Prep release + if: ${{ steps.parse.outputs.should-release }} + id: prep + uses: ./.github/actions/prep-release + with: + release-type: ${{ steps.parse.outputs.release-type }} + version: ${{ steps.parse.outputs.next-version }} + + - name: Release + if: ${{ steps.prep.outputs.in-sync }} + uses: ./.github/actions/release + with: + version: ${{ steps.parse.outputs.next-version }} + changelog: ${{ steps.parse.outputs.changelog }} + issues-closed: ${{ steps.parse.outputs.issues-closed }} + crates-io-token: ${{ secrets.CRATES_IO_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index c17112e..0000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,68 +0,0 @@ -name: Test -on: - push: - branches: - - '**' - paths: - - '**.rs' - - '**.toml' - - webdriver.json - - .github/workflows/test.yml - pull_request: - types: - - synchronize - - opened - schedule: - - cron: 0 7 * * 6 - -jobs: - test: - name: Test - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Install stable toolchain - uses: actions-rs/toolchain@v1 - id: install-stable - with: - toolchain: stable - default: true - - name: Install nightly toolchain - uses: actions-rs/toolchain@v1 - id: install-nightly - with: - toolchain: nightly - - name: Cargo cache - uses: actions/cache@v3 - with: - key: v1-${{ runner.os }}-cargo-${{ steps.install-stable.outputs.rustc_hash }}-${{ steps.install-nightly.outputs.rustc_hash }}-${{ github.ref }}-${{ hashFiles('**/Cargo.lock') }} - path: | - ~/.cargo/bin/ - ~/.cargo/registry/index/ - ~/.cargo/registry/cache/ - ~/.cargo/git/db/ - target/cargo-install/ - target/debug/ - target/wasm32-unknown-unknown/ - target/.rustc_info.json - target/CACHEDIR.TAG - restore-keys: | - v1-${{ runner.os }}-cargo-${{ steps.install-stable.outputs.rustc_hash }}-${{ steps.install-nightly.outputs.rustc_hash }}-refs/heads/master-${{ hashFiles('**/Cargo.lock') }} - v1-${{ runner.os }}-cargo-${{ steps.install-stable.outputs.rustc_hash }}-${{ steps.install-nightly.outputs.rustc_hash }}-refs/heads/master- - v1-${{ runner.os }}-cargo-${{ steps.install-stable.outputs.rustc_hash }}-${{ steps.install-nightly.outputs.rustc_hash }}- - v1-${{ runner.os }}-cargo-${{ steps.install-stable.outputs.rustc_hash }}- - - name: Install CLI deps - run: cargo install --force --debug --target-dir target/cargo-install wasm-pack - - name: Test (stable, no features) - run: wasm-pack test --headless --firefox --chrome --locked --no-default-features - - name: Test (stable, all features) - run: wasm-pack test --headless --firefox --chrome --locked - - name: Test (nightly, no features) - run: rustup run nightly wasm-pack test --headless --firefox --chrome --locked --no-default-features --features nightly - - name: Test (nightly, all features) - run: rustup run nightly wasm-pack test --headless --firefox --chrome --locked --features default,nightly - - name: Test doc generation - run: cargo doc --no-deps - - name: List package contents - run: cargo package --list --locked --target wasm32-unknown-unknown diff --git a/.gitignore b/.gitignore index f686138..494026c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ *.log /target /tmp.js -/.github/generate-changelog/node_modules/