-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
107 additions
and
17 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,117 @@ | ||
name: Release | ||
|
||
permissions: | ||
contents: write | ||
|
||
name: release | ||
on: | ||
push: | ||
tags: | ||
- v[0-9]+.* | ||
|
||
- "[0-9]+.[0-9]+.[0-9]+" | ||
jobs: | ||
release: | ||
name: release ${{ matrix.target }} | ||
create-release: | ||
name: create-release | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
target: [x86_64-pc-windows-gnu, x86_64-unknown-linux-musl, x86_64-apple-darwin] | ||
outputs: | ||
upload_url: ${{ steps.release.outputs.upload_url }} | ||
VERSION: ${{ env.VERSION }} | ||
steps: | ||
- uses: actions/checkout@master | ||
- name: Compile and release | ||
uses: rust-build/[email protected] | ||
- name: Get the release version from the tag | ||
shell: bash | ||
if: env.VERSION == '' | ||
run: | | ||
# Apparently, this is the right way to get a tag name. Really? | ||
# | ||
# See: https://github.community/t5/GitHub-Actions/How-to-get-just-the-tag-name/m-p/32167/highlight/true#M1027 | ||
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | ||
echo "version is: ${{ env.VERSION }}" | ||
- name: Create GitHub release | ||
id: release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
RUSTTARGET: ${{ matrix.target }} | ||
EXTRA_FILES: "README.md LICENSE" | ||
tag_name: ${{ env.VERSION }} | ||
release_name: ${{ env.VERSION }} | ||
|
||
build-release: | ||
name: build-release | ||
needs: ['create-release'] | ||
runs-on: ${{ matrix.os }} | ||
env: | ||
CARGO: cargo | ||
TARGET_DIR: ./target | ||
# Emit backtraces on panics. | ||
RUST_BACKTRACE: 1 | ||
strategy: | ||
matrix: | ||
build: [linux, linux-arm, macos, win-gnu, win32-msvc] | ||
include: | ||
- build: linux | ||
os: ubuntu-latest | ||
rust: stable | ||
target: x86_64-unknown-linux-musl | ||
- build: linux-arm | ||
os: ubuntu-latest | ||
rust: stable | ||
target: arm-unknown-linux-gnueabihf | ||
- build: macos | ||
os: macos-latest | ||
rust: stable | ||
target: x86_64-apple-darwin | ||
- build: win-gnu | ||
os: windows-2019 | ||
rust: stable-x86_64-gnu | ||
target: x86_64-pc-windows-gnu | ||
- build: win32-msvc | ||
os: windows-2019 | ||
rust: stable | ||
target: i686-pc-windows-msvc | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 1 | ||
|
||
- name: Install Rust | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.rust }} | ||
profile: minimal | ||
override: true | ||
target: ${{ matrix.target }} | ||
|
||
- name: Use Cross | ||
shell: bash | ||
run: | | ||
cargo install cross | ||
echo "CARGO=cross" >> $GITHUB_ENV | ||
echo "TARGET_DIR=./target/${{ matrix.target }}" >> $GITHUB_ENV | ||
- name: Show command used for Cargo | ||
run: | | ||
echo "cargo command is: ${{ env.CARGO }}" | ||
echo "target dir is: ${{ env.TARGET_DIR }}" | ||
- name: Build release binary | ||
run: ${{ env.CARGO }} build --verbose --release | ||
|
||
- name: Build archive | ||
shell: bash | ||
run: | | ||
outdir="$(ci/cargo-out-dir "${{ env.TARGET_DIR }}")" | ||
staging="make_dic-${{ needs.create-release.outputs.VERSION }}-${{ matrix.target }}" | ||
cp {README.md,LICENSE} "$staging/" | ||
if [ "${{ matrix.os }}" = "windows-2019" ]; then | ||
cp "target/${{ matrix.target }}/release/make_dic.exe" "$staging/" | ||
7z a "$staging.zip" "$staging" | ||
echo "ASSET=$staging.zip" >> $GITHUB_ENV | ||
else | ||
cp "target/${{ matrix.target }}/release/make_dic" "$staging/" | ||
tar czf "$staging.tar.gz" "$staging" | ||
echo "ASSET=$staging.tar.gz" >> $GITHUB_ENV | ||
fi | ||
- name: Upload release archive | ||
uses: actions/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ needs.create-release.outputs.upload_url }} | ||
asset_path: ${{ env.ASSET }} | ||
asset_name: ${{ env.ASSET }} | ||
asset_content_type: application/octet-stream |