2023-06-01 11:47:58 +12:00
|
|
|
name: Rust Build & Publish
|
2020-12-04 18:07:01 +13:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
2021-11-22 19:46:01 +13:00
|
|
|
paths-ignore:
|
|
|
|
- "**.md"
|
2023-06-01 11:47:58 +12:00
|
|
|
|
2021-11-22 19:46:01 +13:00
|
|
|
branches:
|
2023-06-01 11:47:58 +12:00
|
|
|
- 'main'
|
|
|
|
|
|
|
|
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
|
2020-12-08 08:05:00 +13:00
|
|
|
|
|
|
|
- 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
|
2020-12-08 08:05:00 +13:00
|
|
|
|
2024-11-20 09:48:42 +13:00
|
|
|
- name: Install musl-gcc
|
|
|
|
run: sudo apt-get install musl-tools
|
2024-05-30 12:51:39 +12:00
|
|
|
|
2024-05-30 12:50:38 +12:00
|
|
|
- name: Install cargo musl target
|
|
|
|
run: rustup target add x86_64-unknown-linux-musl
|
|
|
|
|
2023-06-04 06:19:20 +12:00
|
|
|
# Building actions
|
2020-12-08 08:05:00 +13:00
|
|
|
- name: Build
|
2024-05-30 12:47:44 +12:00
|
|
|
run: RUSTFLAGS='-C target-feature=+crt-static' cargo build --release --target x86_64-unknown-linux-musl
|
2021-12-28 10:53:58 +13:00
|
|
|
|
2024-01-03 13:05:36 +13:00
|
|
|
- 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 }}
|
|
|
|
|
2023-06-04 06:19:20 +12:00
|
|
|
- name: Calculate SHA512 checksum
|
2024-05-30 12:47:44 +12:00
|
|
|
run: sha512sum target/x86_64-unknown-linux-musl/release/redlib > redlib.sha512
|
2023-06-04 06:19:20 +12:00
|
|
|
|
|
|
|
- name: Calculate SHA256 checksum
|
2024-05-30 12:47:44 +12:00
|
|
|
run: sha256sum target/x86_64-unknown-linux-musl/release/redlib > redlib.sha256
|
2023-06-04 06:19:20 +12:00
|
|
|
|
2024-09-17 08:29:52 +12:00
|
|
|
- uses: actions/upload-artifact@v4
|
2021-03-27 16:00:47 +13:00
|
|
|
name: Upload a Build Artifact
|
|
|
|
with:
|
2023-12-27 12:25:52 +13:00
|
|
|
name: redlib
|
2023-06-04 06:19:20 +12:00
|
|
|
path: |
|
2024-05-30 12:47:44 +12:00
|
|
|
target/x86_64-unknown-linux-musl/release/redlib
|
2023-12-27 12:25:52 +13:00
|
|
|
redlib.sha512
|
|
|
|
redlib.sha256
|
2021-03-27 10:48:00 +13:00
|
|
|
|
2023-06-04 06:19:20 +12:00
|
|
|
|
2021-03-27 10:48:00 +13:00
|
|
|
- name: Release
|
|
|
|
uses: softprops/action-gh-release@v1
|
2024-01-03 10:45:31 +13:00
|
|
|
if: github.base_ref != 'main' && github.event_name == 'release'
|
2020-12-08 08:05:00 +13:00
|
|
|
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
|
2021-03-28 09:11:05 +13:00
|
|
|
files: |
|
2024-05-30 12:47:44 +12:00
|
|
|
target/x86_64-unknown-linux-musl/release/redlib
|
2023-12-27 12:25:52 +13:00
|
|
|
redlib.sha512
|
|
|
|
redlib.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 }}
|