Skip to content

Commit

Permalink
ci: update release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
tfx2001 committed Apr 24, 2022
1 parent 97257b4 commit d648e1b
Showing 1 changed file with 65 additions and 12 deletions.
77 changes: 65 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,75 @@
name: Release
# Reference:
# https://eugene-babichenko.github.io/blog/2020/05/09/github-actions-cross-platform-auto-releases/

name: Release
on:
release:
types: [created]

types: [ created ]
env:
BIN_NAME: hpm_isp
jobs:
release:
name: release ${{ matrix.target }}
runs-on: ubuntu-latest
build-release:
name: build-release
strategy:
fail-fast: false
matrix:
target: [x86_64-pc-windows-gnu]
build: [linux, macos, win-msvc]
include:
- build: linux
os: ubuntu-latest
rust: stable
target: x86_64-unknown-linux-gnu
- build: macos
os: macos-latest
rust: stable
target: x86_64-apple-darwin
- build: win-msvc
os: windows-2019
rust: stable
target: x86_64-pc-windows-msvc
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@master
- name: Compile and release
uses: rust-build/rust-build.action@latest
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install packages (Ubuntu)
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends libusb-1.0-0-dev
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
profile: minimal
override: true
target: ${{ matrix.target }}
- name: Build release binary
run: cargo build --target ${{ matrix.target }} --verbose --release
- name: Build archive
shell: bash
run: |
outdir="./target/${{ env.TARGET_DIR }}/release"
staging="${{ env.BIN_NAME }}-${{ github.event.release.tag_name }}-${{ matrix.target }}"
mkdir -p "$staging"/{complete,doc}
cp {README.md,LICENSE} "$staging/"
if [ "${{ matrix.os }}" = "windows-2019" ]; then
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe" "$staging/"
cd "$staging"
7z a "../$staging.zip" .
echo "ASSET=$staging.zip" >> $GITHUB_ENV
else
cp "target/${{ matrix.target }}/release/${{ env.BIN_NAME }}" "$staging/"
tar czf "$staging.tar.gz" -C "$staging" .
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV
fi
- name: Upload release archive
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUSTTARGET: ${{ matrix.target }}
EXTRA_FILES: "README.md LICENSE"
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ env.ASSET }}
asset_name: ${{ env.ASSET }}
asset_content_type: application/octet-stream

0 comments on commit d648e1b

Please sign in to comment.