This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
Build and Release #30
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: Build and Release | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: | |
permissions: | |
contents: write | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
native-build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- os: ubuntu-latest | |
target: x86_64-unknown-linux-gnu | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
extension: .exe | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
run: | | |
rustup update --no-self-update stable | |
rustup target add ${{ matrix.target }} | |
rustup default stable | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
env: | |
cache-name: cache-cargo-${{ matrix.target }} | |
with: | |
prefix-key: "downapk-v1" | |
shared-key: ${{ runner.os }}-cargo- | |
key: ${{ runner.os }}-cargo-${{ matrix.target }}- | |
cache-directories: | | |
C:\Users\runneradmin\.cargo | |
/Users/runner/.cargo | |
- name: Build for ${{ matrix.target }} | |
run: cargo build --release --target ${{ matrix.target }} | |
- name: Upload binaries to release | |
if: ${{ github.event_name == 'release' }} | |
run: | | |
mv target/${{ matrix.target }}/release/downapk${{ matrix.extension }} target/${{ matrix.target }}/release/downapk-${{ matrix.target }}${{ matrix.extension }} | |
gh release upload ${{ github.ref_name }} target/${{ matrix.target }}/release/downapk-${{ matrix.target }}${{ matrix.extension }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
cross-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- target: aarch64-unknown-linux-gnu | |
- target: aarch64-linux-android | |
- target: armv7-unknown-linux-gnueabihf | |
- target: armv7-linux-androideabi | |
- target: x86_64-linux-android | |
- target: i686-unknown-linux-gnu | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Rust | |
run: | | |
rustup update --no-self-update stable | |
rustup target add ${{ matrix.target }} | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
env: | |
cache-name: cache-cargo-${{ matrix.target }} | |
with: | |
prefix-key: "downapk-v1" | |
shared-key: ${{ runner.os }}-cargo- | |
key: ${{ runner.os }}-cargo-${{ matrix.target }}- | |
- name: Install dependencies | |
run: | | |
cargo install cross --git https://github.com/cross-rs/cross | |
- name: Build ${{ matrix.target }} | |
run: cross build --release --target ${{ matrix.target }} | |
- name: Upload binaries to release | |
if: ${{ github.event_name == 'release' }} | |
shell: bash | |
run: | | |
mv target/${{ matrix.target }}/release/downapk target/${{ matrix.target }}/release/downapk-${{ matrix.target }} | |
gh release upload ${{ github.ref_name }} target/${{ matrix.target }}/release/downapk-${{ matrix.target }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
needs: [native-build, cross-build] | |
if: ${{ github.event_name == 'release' }} | |
runs-on: ubuntu-latest | |
name: "Publish to Cargo" | |
environment: | |
name: Cargo | |
url: https://crates.io/crates/downapk | |
steps: | |
- uses: actions/checkout@master | |
# Use caching to speed up your build | |
- name: Setup Cache | |
uses: Swatinem/rust-cache@v2 | |
env: | |
cache-name: cache-cargo | |
with: | |
prefix-key: "downapk-v1" | |
shared-key: ${{ runner.os }}-cargo- | |
key: ${{ runner.os }}-cargo- | |
- name: Setup cargo | |
run: | | |
rustup update --no-self-update stable | |
- name: Cargo publish | |
run: cargo publish | |
env: | |
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | |