Merge pull request #88 from ButteredCats/better_preview_handling #4
This file contains 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 Build & Publish | |
on: | |
push: | |
paths-ignore: | |
- "**.md" | |
branches: | |
- 'main' | |
release: | |
types: [published] | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout sources | |
uses: actions/checkout@v3 | |
- name: Cache Packages | |
uses: Swatinem/rust-cache@v2 | |
- name: Install stable toolchain | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
toolchain: stable | |
# Building actions | |
- name: Build | |
run: RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-gnu | |
- name: Versions | |
id: version | |
run: echo "VERSION=$(cargo metadata --format-version 1 --no-deps | jq .packages[0].version -r | sed 's/^/v/')" >> "$GITHUB_OUTPUT" | |
# Publishing actions | |
- name: Publish to crates.io | |
if: github.event_name == 'release' | |
run: cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }} | |
- name: Calculate SHA512 checksum | |
run: sha512sum target/x86_64-unknown-linux-gnu/release/redlib > redlib.sha512 | |
- name: Calculate SHA256 checksum | |
run: sha256sum target/x86_64-unknown-linux-gnu/release/redlib > redlib.sha256 | |
- uses: actions/upload-artifact@v3 | |
name: Upload a Build Artifact | |
with: | |
name: redlib | |
path: | | |
target/x86_64-unknown-linux-gnu/release/redlib | |
redlib.sha512 | |
redlib.sha256 | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
if: github.base_ref != 'main' && github.event_name == 'release' | |
with: | |
tag_name: ${{ steps.version.outputs.VERSION }} | |
name: ${{ steps.version.outputs.VERSION }} - ${{ github.event.head_commit.message }} | |
draft: true | |
files: | | |
target/x86_64-unknown-linux-gnu/release/redlib | |
redlib.sha512 | |
redlib.sha256 | |
body: | | |
- ${{ github.event.head_commit.message }} ${{ github.sha }} | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |