Skip to content

wip

wip #23

Workflow file for this run

name: Rust
on:
push:
branches: ["feature/ci-add-musl-support", "release/*"]
# pull_request:
# branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
# TODO add musl to CI see DEVELOPMENT.md
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Run tests
run: cargo test
prepare_release:
needs: test
name: Prepare Github Release
runs-on: ubuntu-latest
outputs:
pkg_ver: ${{ steps.capture_version_from_cargo.outputs.pkg_ver }}
steps:
- name: Checkout Repo
uses: actions/checkout@v4
# TODO create a cargo crate to query data from Cargo.toml
- id: capture_version_from_cargo
name: Capture Version from Cargo.toml
run: |
ver=$(cat Cargo.toml | grep -e '^version = ".*"$' | sed 's/version = "\(.*\)"/\1/')
echo "pkg_ver=$ver" >> "$GITHUB_OUTPUT"
- name: Create Github Release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
PKG_VER: ${{ steps.capture_version_from_cargo.outputs.pkg_ver }}
run: |
gh release create \
--title v$PKG_VER --notes-file RELEASE.md $PKG_VER
publish_crate:
needs: prepare_release
name: publish crate
runs-on: ubuntu-latest
strategy:
matrix:
build:
- linux gnu x86_64
- linux musl x64
include:
- build: linux musl x64
os: ubuntu-latest
rust: stable
rust_target: x86_64-unknown-linux-musl
- build: linux gnu x86_64
os: ubuntu-latest
rust: stable
rust_target: x86_64-unknown-linux-gnu
steps:
- name: Checkout Repo
uses: actions/checkout@v4
- name: Install Dependencies - musl
if: matrix.rust_target == 'x86_64-unknown-linux-musl'
run: |
sudo apt-get install -y --no-install-recommends musl-tools
- name: Extra Cargo
run: cargo install cargo-caw-publish
- name: Build
run: cargo build -r --target ${{ matrix.rust_target }}
- name: Adjust Target Name
run: |
cp \
target/${{ matrix.rust_target }}/release/http_status_code_check \
target/${{ matrix.rust_target }}/release/http_status_code_check-${{ matrix.rust_target }}
# TODO maybe split this publish into two: crates.io and github?
# - name: Upload Target
# uses: actions/upload-artifact@v2
# with:
# name: ${{ matrix.rust_target }}
# path: target/${{ matrix.rust_target }}/release/http_status_code_check-${{ matrix.rust_target }}
# retention-days: 1
# - name: Publish to crates.io
# env:
# CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
# run: cargo caw-publish
- name: Publish to Github Releases
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
# TODO resolving to blank
PKG_VER: ${{ needs.prepare_release.outputs.pkg_ver }}
run: |
gh release upload \
$PKG_VER \
target/${{ matrix.rust_target }}/release/http_status_code_check-${{ matrix.rust_target }}