Skip to content

feat: auto release rust crates #101

feat: auto release rust crates

feat: auto release rust crates #101

Workflow file for this run

# -------------------------------------------------------------------
# ------------------------------- WARNING ---------------------------
# -------------------------------------------------------------------
#
# This file was automatically generated by rust-gh-workflows using the
# gh-workflow-gen bin. You should add and commit this file to your
# git repository. **DO NOT EDIT THIS FILE BY HAND!** Any manual changes
# will be lost if the file is regenerated.
#
# To make modifications, update your `build.rs` configuration to adjust
# the workflow description as needed, then regenerate this file to apply
# those changes.
#
# -------------------------------------------------------------------
# ----------------------------- END WARNING -------------------------
# -------------------------------------------------------------------
name: Build and Test
env:
RUSTFLAGS: -Dwarnings
on:
push:
branches:
- main
pull_request_target:
types:
- opened
- synchronize
- reopened
branches:
- main
permissions:
contents: read
jobs:
build:
name: Build and Test
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable, nightly
components: clippy, rustfmt
- name: Cargo Test
run: cargo test --all-features --workspace
- name: Cargo Fmt
run: cargo +nightly fmt --check
- name: Cargo Clippy
run: cargo +nightly clippy --all-features --workspace -- -D warnings
draft_release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
name: Draft release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- id: create_release
uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- id: set_output
name: Set Output for Later Jobs
run: echo "create_release_name=${{ steps.create_release.outputs.name }}" >> $GITHUB_OUTPUT && echo "create_release_id=${{ steps.create_release.outputs.id }}" >> $GITHUB_OUTPUT
permissions:
contents: write
outputs:
create_release_name: ${{ steps.set_output.outputs.create_release_name }}
create_release_id: ${{ steps.set_output.outputs.create_release_id }}
release:
name: Create release
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Setup Rust Toolchain
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: stable
- run: 'cargo fetch '
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: sed -i.bak "s/version = \".*\"/version = \"$NEW_VERSION\"/" Cargo.toml
env:
NEW_VERSION: ${{ needs.draft_release.outputs.create_release_name }}
- run: echo $CRATES_TOKEN | cargo login
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
- run: cargo publish --token $CRATES_TOKEN
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
- run: flyctl deploy --remote-only
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}