Last active
August 29, 2024 17:55
-
-
Save kaleidawave/16b0fc93459dd4dddc05d91955a40816 to your computer and use it in GitHub Desktop.
GH action for Rust
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release crate | |
on: | |
workflow_dispatch: | |
inputs: | |
version-one: | |
description: "major/minor/patch or semver" | |
required: false | |
default: "patch" | |
version-two: | |
description: "major/minor/patch or semver" | |
required: false | |
default: "none" | |
concurrency: release-crate | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set git credentials | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Crates publish | |
uses: kaleidawave/crates-release-gh-action@main | |
id: release | |
with: | |
version: | | |
{ | |
"crate-one": "${{ github.event.inputs.version-one }}", | |
"crate-two": "${{ github.event.inputs.version-two }}" | |
} | |
crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Push updated Cargo.toml | |
run: | | |
git add . | |
git commit -m "Release: ${{ steps.release.outputs.new-versions-description }}" | |
echo '${{ steps.release.outputs.new-versions }}' | jq -r '.[]' | while read -r update; do | |
git tag "release/$update" | |
done | |
git push --tags origin main | |
- name: Discord | |
uses: rjstone/discord-webhook-notify@master | |
with: | |
severity: info | |
text: "Released version ${{ steps.release.outputs.new-versions-description }}" | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK_ENDPOINT }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release crate | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: "major/minor/patch or semver" | |
required: false | |
default: "patch" | |
concurrency: release-crate | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set git credentials | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
- name: Crates publish | |
uses: kaleidawave/crates-release-gh-action@main | |
id: release | |
with: | |
version: ${{ github.event.inputs.version }} | |
crates-token: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Push updated Cargo.toml | |
run: | | |
git add . | |
git commit -m "Release: ${{ steps.release.outputs.new-versions-description }}" | |
git tag "release/${{ steps.release.outputs.new-version }}" | |
git push --tags origin main | |
- name: Discord | |
uses: rjstone/discord-webhook-notify@master | |
with: | |
severity: info | |
text: "Released version ${{ steps.release.outputs.new-versions-description }}" | |
webhookUrl: ${{ secrets.DISCORD_WEBHOOK_ENDPOINT }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Rust | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
env: | |
CARGO_TERM_COLOR: always | |
CACHE_PATHS: | | |
~/.cargo/bin/ | |
~/.cargo/registry/index/ | |
~/.cargo/registry/cache/ | |
~/.cargo/git/db/ | |
target/ | |
jobs: | |
validity: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Check source is valid | |
run: cargo check --workspace | |
formating: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check formatting with rustfmt | |
run: cargo fmt --all --check | |
- uses: brndnmtthws/rust-action-cargo-binstall@v1 | |
with: | |
packages: taplo-cli | |
- name: Check TOML formatting with taplo | |
run: | | |
taplo fmt --check **/*/Cargo.toml | |
tests: | |
needs: validity | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Run all tests | |
run: cargo test --workspace --verbose --all-features | |
clippy: | |
needs: validity | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/cache@v4 | |
with: | |
path: ${{ env.CACHE_PATHS }} | |
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
- name: Lint code with clippy | |
run: cargo clippy | |
publish-ability: | |
runs-on: ubuntu-latest | |
if: false | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check that it will publish to crates | |
run: | | |
cargo metadata --offline --format-version 1 --no-deps | jq -r ".workspace_members[]" | while read -r _n _v pathInfo ; do | |
cd ${pathInfo:13:-1} | |
cargo publish --no-verify --dry-run | |
done | |
shell: bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment