add develop workflow action #1
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: Pre-release dorcs | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
build-and-upload: | |
name: Build and upload | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- build: linux | |
os: ubuntu-latest | |
target: x86_64-unknown-linux-musl | |
# - build: macos | # NOPE I DONT DO THIS. YOU'RE RICH ENOUGH TO DO IT YOURSELF. | |
# os: macos-latest | |
# target: x86_64-apple-darwin | |
- build: windows-gnu | |
os: ubuntu-latest | |
target: x86_64-pc-windows-gnu | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
# Get version from cargo.toml | |
- name: Get version | |
id: get_version | |
run: echo "VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')" >> $GITHUB_ENV | |
- name: Install Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
# Make Rust compile to our target (defined in the matrix) | |
targets: ${{ matrix.target }} | |
- name: Install mingw-w64 | |
if: matrix.build == 'windows-gnu' | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y mingw-w64 zip | |
- name: Build | |
uses: actions-rs/cargo@v1 | |
with: | |
command: build | |
args: --verbose --release --target ${{ matrix.target }} | |
- name: Build archive | |
shell: bash | |
run: | | |
binary_name="dorcs" | |
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" | |
mkdir "$dirname" | |
if [ "${{ matrix.build}}" = "windows-gnu" ]; then | |
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname/$binary_name.exe" | |
echo "ASSET=$dirname/$binary_name.exe" >> $GITHUB_ENV | |
else | |
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname/$binary_name" | |
echo "ASSET=$dirname/$binary_name" >> $GITHUB_ENV | |
fi | |
- name: Tag commit | |
run: | | |
git tag ${{ env.VERSION }} | |
git push origin ${{ env.VERSION }} | |
- name: Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
${{ env.ASSET }} | |
tag_name: ${{ env.VERSION }} | |
prerelease: true |