redsunlib/.github/workflows/main-rust.yml

95 lines
2.7 KiB
YAML
Raw Normal View History

2023-06-01 11:47:58 +12:00
name: Rust Build & Publish
2020-12-04 18:07:01 +13:00
on:
push:
paths-ignore:
- "**.md"
2023-06-01 11:47:58 +12:00
branches:
2023-06-01 11:47:58 +12:00
- 'main'
- 'master'
release:
types: [published]
2020-12-04 18:07:01 +13:00
env:
CARGO_TERM_COLOR: always
jobs:
build:
2023-06-01 11:47:58 +12:00
runs-on: ubuntu-latest
2020-12-04 18:07:01 +13:00
steps:
2023-06-01 11:47:58 +12:00
- name: Checkout sources
uses: actions/checkout@v3
- name: Cache Packages
2023-06-01 11:50:38 +12:00
uses: Swatinem/rust-cache@v2
2023-06-01 11:47:58 +12:00
- name: Install stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
# Building actions
- name: Build
run: cargo build --release
2021-12-28 10:53:58 +13:00
- name: Calculate SHA512 checksum
run: sha512sum target/release/libreddit > libreddit.sha512
- name: Calculate SHA256 checksum
run: sha256sum target/release/libreddit > libreddit.sha256
- name: Build MUSL
run: cargo build --release --target x86_64-unknown-linux-musl
- name: Calculate MUSL SHA512 checksum
run: sha512sum target/x86_64-unknown-linux-musl/release/libreddit > libreddit-musl.sha512
- name: Calculate MUSL SHA256 checksum
run: sha256sum target/x86_64-unknown-linux-musl/release/libreddit > libreddit-musl.sha256
- name: Move MUSL binary
run: mv target/x86_64-unknown-linux-musl/release/libreddit target/x86_64-unknown-linux-musl/release/libreddit-musl
2021-03-27 16:00:47 +13:00
2023-06-01 11:47:58 +12:00
- uses: actions/upload-artifact@v3
2021-03-27 16:00:47 +13:00
name: Upload a Build Artifact
with:
name: libreddit
path: |
2023-06-04 06:24:19 +12:00
target/release/libreddit
target/x86_64-unknown-linux-musl/release/libreddit-musl
*.sha512
*.sha256
2021-03-27 10:48:00 +13:00
- name: Versions
id: version
2023-06-01 11:47:58 +12:00
run: echo "VERSION=$(cargo metadata --format-version 1 --no-deps | jq .packages[0].version -r | sed 's/^/v/')" >> "$GITHUB_OUTPUT"
2021-03-27 10:48:00 +13:00
# Publishing actions
- name: Publish to crates.io
if: github.event_name == 'release'
run: cargo publish --no-verify --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
2021-03-27 10:48:00 +13:00
- name: Release
uses: softprops/action-gh-release@v1
if: github.base_ref != 'master' && github.event_name == 'release'
with:
2023-06-01 11:47:58 +12:00
tag_name: ${{ steps.version.outputs.VERSION }}
name: ${{ steps.version.outputs.VERSION }} - ${{ github.event.head_commit.message }}
2021-03-27 10:48:00 +13:00
draft: true
files: |
target/release/libreddit
libreddit.sha512
2023-06-01 11:47:58 +12:00
libreddit.sha256
target/x86_64-unknown-linux-musl/release/libreddit-musl
libreddit-musl.sha512
libreddit-musl.sha256
2021-03-27 10:48:00 +13:00
body: |
2021-12-28 07:15:25 +13:00
- ${{ github.event.head_commit.message }} ${{ github.sha }}
generate_release_notes: true
2021-03-27 10:48:00 +13:00
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}