This repository has been archived by the owner on Oct 29, 2024. It is now read-only.
v0.5.0 #12
Workflow file for this run
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 | |
filename: downapk-linux-x86_64 | |
- os: windows-latest | |
target: x86_64-pc-windows-msvc | |
filename: downapk-windows-x86_64.exe | |
extension: .exe | |
- os: macos-latest | |
target: x86_64-apple-darwin | |
filename: downapk-darwin-x86_64 | |
- os: macos-latest | |
target: aarch64-apple-darwin | |
filename: downapk-darwin-aarch64 | |
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: Compress action step | |
uses: a7ul/tar-action@master | |
with: | |
command: c | |
cwd: target/${{ matrix.target }}/release | |
files: | | |
downapk${{ matrix.extension }} | |
outPath: target/${{ matrix.target }}/release/downapk-${{ matrix.target }}-${{ github.event.release.tag_name }}.tar.gz | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: target/${{ matrix.target }}/release/downapk${{ matrix.extension }} | |
asset_name: ${{ matrix.filename }} | |
tag: ${{ github.ref }} | |
file_glob: false | |
- name: Upload tar.gz to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: target/${{ matrix.target }}/release/downapk-${{ matrix.target }}-${{ github.event.release.tag_name }}.tar.gz | |
asset_name: downapk-${{ matrix.target }}-${{ github.event.release.tag_name }}.tar.gz | |
tag: ${{ github.ref }} | |
file_glob: false | |
cross-build: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- target: aarch64-unknown-linux-gnu | |
filename: downapk-linux-aarch64 | |
- target: aarch64-linux-android | |
filename: downapk-android-aarch64 | |
- target: armv7-unknown-linux-gnueabihf | |
filename: downapk-linux-armv7 | |
- target: armv7-linux-androideabi | |
filename: downapk-android-armv7 | |
- target: x86_64-linux-android | |
filename: downapk-android-x86_64 | |
- target: i686-unknown-linux-gnu | |
filename: downapk-linux-i686 | |
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: Compress action step | |
uses: a7ul/tar-action@master | |
with: | |
command: c | |
cwd: target/${{ matrix.target }}/release | |
files: | | |
downapk | |
outPath: target/${{ matrix.target }}/release/downapk-${{ matrix.target }}-${{ github.event.release.tag_name }}.tar.gz | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: target/${{ matrix.target }}/release/downapk | |
asset_name: ${{ matrix.filename }} | |
tag: ${{ github.ref }} | |
file_glob: false | |
- name: Upload tar.gz to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: target/${{ matrix.target }}/release/downapk-${{ matrix.target }}-${{ github.event.release.tag_name }}.tar.gz | |
asset_name: downapk-${{ matrix.target }}-${{ github.event.release.tag_name }}.tar.gz | |
tag: ${{ github.ref }} | |
file_glob: false | |
publish: | |
needs: [native-build, cross-build] | |
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 }} | |