Build and Release #10
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-musl | |
# - os: windows-latest | |
# target: x86_64-pc-windows-msvc | |
# extension: .exe | |
# - os: windows-latest | |
# target: i686-pc-windows-msvc | |
# extension: .exe | |
# - os: windows-latest | |
# target: aarch64-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: "prevanced-backend-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/prevanced-backend target/${{ matrix.target }}/release/prevanced-backend-${{ github.ref_name }} | |
gh release upload ${{ github.ref_name }} target/${{ matrix.target }}/release/prevanced-backend-${{ github.ref_name }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish: | |
runs-on: ubuntu-latest | |
needs: native-build | |
if: github.event_name == 'release' | |
steps: | |
- name: Publish server | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "PreVanced" | |
git clone https://prevanced:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/prevanced/backend | |
cd notification | |
sed -E 's/v[0-9]+\.[0-9]+\.[0-9]+/${{ github.ref_name }}/g' Dockerfile > temp_Dockerfile | |
mv temp_Dockerfile Dockerfile | |
git add Dockerfile | |
git commit -m "Update prevanced-backend to ${{ github.ref_name }}" | |
git push origin main |