feat: docker and cross release #3
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
# referred from: https://github.com/PyO3/maturin/blob/main/.github/workflows/release.yml | ||
name: Release | ||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.[0-9]+.[0-9]+ | ||
jobs: | ||
created_release : | ||
if: startsWith(github.ref, 'refs/tags/') | ||
name: release ${{ matrix.target }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Code | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
fetch-tags: true | ||
- name: Update CHANGELOG | ||
id: changelog | ||
uses: requarks/changelog-action@v1 | ||
with: | ||
token: ${{ github.token }} | ||
tag: ${{ github.ref_name }} | ||
- name: Create Release | ||
uses: ncipollo/[email protected] | ||
with: | ||
allowUpdates: true | ||
draft: false | ||
makeLatest: true | ||
name: ${{ github.ref_name }} | ||
body: ${{ steps.changelog.outputs.changes }} | ||
token: ${{ github.token }} | ||
release: | ||
name: release | ||
needs: create_release | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
include: | ||
- target: x86_64-apple-darwin | ||
os: macos-latest | ||
archive: tar.gz | ||
- target: x86_64-pc-windows-gnu | ||
os: windows-latest | ||
ext: .exe | ||
archive: zip | ||
- target: x86_64-pc-windows-msvc | ||
os: windows-latest | ||
ext: .exe | ||
archive: zip | ||
- target: x86_64-unknown-linux-gnu | ||
os: ubuntu-latest | ||
archive: tar.gz | ||
- target: x86_64-unknown-linux-musl | ||
os: ubuntu-latest | ||
archive: tar.gz | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Cargo build | ||
run: | | ||
rustup toolchain install nightly --profile minimal -t ${{ matrix.target }} | ||
cargo +nightly build --release --target ${{ matrix.target }} | ||
env: | ||
RUSTFLAGS: -C strip=symbols | ||
- name: Packaging Archive .zip | ||
if: ${{ startsWith(matrix.os, 'windows-latest') }} | ||
run: | | ||
Get-ChildItem -Path .\README.md,.\config.example.toml,.\target\x86_64-pc-windows-msvc\release\ -Filter *.exe | | ||
Compress-Archive -DestinationPath jsdelivr_proxy-${{ matrix.target }}.zip -Force | ||
- name: Packaging Archive .tar.gz | ||
if: ${{ !startsWith(matrix.os, 'windows-latest') }} | ||
run: | | ||
mkdir -p ./tmp && cp ./README.md ./config.example.toml ./target/${{ matrix.target }}/release/jsdelivr_proxy ./tmp && cd ./tmp && tar -czvf ../jsdelivr_proxy-${{ matrix.target }}.tar.gz . && cd .. && rm -rf ./tmp | ||
- name: Upload asset | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ github.token }} | ||
tag: ${{ github.ref }} | ||
file: jsdelivr_proxy-${{ matrix.target }}.${{ matrix.archive }} | ||
asset_name: jsdelivr_proxy-${{ matrix.target }}.${{ matrix.archive }} | ||
docker-release: |