Merge pull request #4 from jprosenbaum/dockerize-for-github-execution #38
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: Release workflow | |
on: | |
push: | |
tags: | |
env: | |
CARGO_INCREMENTAL: 0 | |
CARGO_NET_RETRY: 10 | |
RUST_BACKTRACE: short | |
RUSTFLAGS: "-D warnings" | |
RUSTUP_MAX_RETRIES: 10 | |
jobs: | |
setup_client: | |
name: Setup Shortcut OpenAPI client | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Setup Shortcut client | |
uses: ./.github/actions/setup | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shortcut_client | |
path: | | |
shortcut_client/src | |
shortcut_client/Cargo.toml | |
if-no-files-found: error | |
retention-days: 1 | |
build_release: | |
name: Build release ${{ matrix.target }} | |
needs: [setup_client] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false # don't fail other jobs if one fails | |
matrix: | |
build: [x86_64-linux, x86_64-macos, x86_64-windows] | |
include: | |
- build: x86_64-linux | |
os: ubuntu-20.04 | |
rust: stable | |
target: x86_64-unknown-linux-gnu | |
cross: false | |
- build: x86_64-macos | |
os: macos-latest | |
rust: stable | |
target: x86_64-apple-darwin | |
cross: false | |
- build: x86_64-windows | |
os: windows-2019 | |
rust: stable | |
target: x86_64-pc-windows-msvc | |
cross: false | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Download Shortcut client | |
uses: actions/download-artifact@v3 | |
with: | |
name: shortcut_client | |
path: shortcut_client | |
- name: Build release binary | |
uses: actions-rs/cargo@v1 | |
with: | |
use-cross: ${{ matrix.cross }} | |
command: build | |
args: --release --locked --target ${{ matrix.target }} | |
- name: Strip release binary (linux and macos) | |
if: matrix.build == 'x86_64-linux' || matrix.build == 'x86_64-macos' | |
run: strip "target/${{ matrix.target }}/release/shortcut_release_helper" | |
- name: Build archive | |
shell: bash | |
run: | | |
mkdir -p dist | |
if [ "${{ matrix.os }}" = "windows-2019" ]; then | |
cp "target/${{ matrix.target }}/release/shortcut_release_helper.exe" "dist/" | |
else | |
cp "target/${{ matrix.target }}/release/shortcut_release_helper" "dist/" | |
fi | |
cp shortcut_release_helper/LICENSE dist | |
cp README.md dist | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: shortcut_release_helper-${{ matrix.build }} | |
path: dist/shortcut_release_helper-* | |
retention-days: 1 | |
publish: | |
name: Publish | |
needs: [build_release] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: dist | |
- shell: bash | |
run: tree | |
- name: Calculate tag name | |
run: | | |
name=dev | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
name=${GITHUB_REF:10} | |
fi | |
echo ::set-output name=val::$name | |
echo TAG=$name >> $GITHUB_ENV | |
id: tagname | |
- name: Upload binaries to release | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: dist/shortcut_release_helper-* | |
file_glob: true | |
tag: ${{ steps.tagname.outputs.val }} | |
overwrite: true |