refactor: optimize some functions #3
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: Continuous Deployment | ||
on: | ||
push: | ||
tags: | ||
- "v*.*.*" | ||
jobs: | ||
publish-github: | ||
name: Publish on GitHub | ||
needs: generate-changelog | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
matrix: | ||
build: [linux-gnu, linux-musl, win-msvc, win32-msvc, macos] | ||
include: | ||
- BUILD: linux-gnu | ||
OS: ubuntu-18.04 | ||
TOOLCHAIN: stable | ||
TARGET: x86_64-unknown-linux-gnu | ||
- BUILD: linux-musl | ||
OS: ubuntu-18.04 | ||
TOOLCHAIN: stable | ||
TARGET: x86_64-unknown-linux-musl | ||
- BUILD: win-msvc | ||
OS: windows-2019 | ||
TOOLCHAIN: stable | ||
TARGET: x86_64-pc-windows-msvc | ||
- BUILD: win32-msvc | ||
OS: windows-2019 | ||
TOOLCHAIN: stable | ||
TARGET: i686-pc-windows-msvc | ||
- BUILD: macos | ||
OS: macos-10.15 | ||
TOOLCHAIN: stable | ||
TARGET: x86_64-apple-darwin | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@main | ||
- name: Set the release version | ||
shell: bash | ||
run: echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV | ||
- name: Install musl-tools | ||
if: matrix.TARGET == 'x86_64-unknown-linux-musl' | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install -y --no-install-recommends \ | ||
--allow-unauthenticated musl-tools | ||
- name: Install Rust toolchain | ||
uses: actions-rs/toolchain@v1 | ||
with: | ||
toolchain: ${{ matrix.TOOLCHAIN }} | ||
target: ${{ matrix.TARGET }} | ||
override: true | ||
- name: Build | ||
run: cargo build --release --locked --target ${{ matrix.TARGET }} | ||
- name: Prepare release assets | ||
shell: bash | ||
run: | | ||
mkdir -p release | ||
cp {LICENSE,README.md} release/ | ||
if [ "${{ matrix.OS }}" = "windows-2019" ]; then | ||
cp target/${{ matrix.TARGET }}/release/xgt.exe release/ | ||
else | ||
cp target/${{ matrix.TARGET }}/release/xgt release/ | ||
fi | ||
mv release/ xgt-${{ env.RELEASE_VERSION }}/ | ||
- name: Create release artifacts | ||
shell: bash | ||
run: | | ||
if [ "${{ matrix.OS }}" = "windows-2019" ]; then | ||
7z a -tzip "xgt-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.zip" \ | ||
xgt-${{ env.RELEASE_VERSION }}/ | ||
else | ||
tar -czvf xgt-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \ | ||
xgt-${{ env.RELEASE_VERSION }}/ | ||
shasum -a 512 xgt-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz \ | ||
> xgt-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}.tar.gz.sha512 | ||
fi | ||
- name: Upload the release | ||
uses: svenstaro/upload-release-action@v2 | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
file: xgt-${{ env.RELEASE_VERSION }}-${{ matrix.TARGET }}* | ||
file_glob: true | ||
overwrite: true | ||
tag: ${{ github.ref }} | ||
release_name: "Release v${{ env.RELEASE_VERSION }}" | ||
body: "${{ needs.generate-changelog.outputs.release_body }}" |