pesde/.github/workflows/release.yaml

106 lines
3 KiB
YAML
Raw Normal View History

2024-03-04 20:18:49 +00:00
name: Release
on:
push:
tags:
- v*
2024-07-26 17:47:53 +01:00
env:
BIN_NAME: pesde
2024-03-04 20:18:49 +00:00
jobs:
build:
strategy:
matrix:
2024-07-26 17:47:53 +01:00
include:
- os: ubuntu-latest
host: linux
arch: x86_64
target: x86_64-unknown-linux-gnu
2024-03-04 20:18:49 +00:00
2024-07-26 17:47:53 +01:00
- os: windows-latest
host: windows
arch: x86_64
target: x86_64-pc-windows-msvc
2024-03-04 20:18:49 +00:00
2024-07-26 17:47:53 +01:00
- os: macos-13
host: macos
arch: x86_64
target: x86_64-apple-darwin
2024-03-04 20:18:49 +00:00
2024-07-26 17:47:53 +01:00
- os: macos-latest
host: macos
arch: aarch64
target: aarch64-apple-darwin
2024-03-04 20:18:49 +00:00
runs-on: ${{ matrix.os }}
name: Build for ${{ matrix.host }}-${{ matrix.arch }}
2024-03-04 20:18:49 +00:00
steps:
- uses: actions/checkout@v4
- name: Set env
shell: bash
run: |
2024-07-26 17:47:53 +01:00
ARCHIVE_NAME=${{ env.BIN_NAME }}-$(echo ${{ github.ref_name }} | cut -c 2-)-${{ matrix.host }}-${{ matrix.arch }}
2024-03-04 20:18:49 +00:00
echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> $GITHUB_ENV
- name: Build
run: cargo build --bins --all-features --release --target ${{ matrix.target }} --locked
- name: Archive
shell: bash
run: |
if [ ${{ matrix.host }} = "windows" ]; then
2024-07-26 17:47:53 +01:00
mv target/${{ matrix.target }}/release/${{ env.BIN_NAME }}.exe ${{ env.BIN_NAME }}.exe
7z a ${{ env.ARCHIVE_NAME }}.zip ${{ env.BIN_NAME }}.exe
tar -czf ${{ env.ARCHIVE_NAME }}.tar.gz ${{ env.BIN_NAME }}.exe
2024-03-04 20:18:49 +00:00
else
2024-07-26 17:47:53 +01:00
mv target/${{ matrix.target }}/release/${{ env.BIN_NAME }} ${{ env.BIN_NAME }}
zip -r ${{ env.ARCHIVE_NAME }}.zip ${{ env.BIN_NAME }}
tar -czf ${{ env.ARCHIVE_NAME }}.tar.gz ${{ env.BIN_NAME }}
2024-03-04 20:18:49 +00:00
fi
2024-07-26 17:47:53 +01:00
- name: Upload zip artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.ARCHIVE_NAME }}.zip
path: ${{ env.ARCHIVE_NAME }}.zip
- name: Upload tar.gz artifact
2024-03-04 20:18:49 +00:00
uses: actions/upload-artifact@v4
with:
2024-07-26 17:47:53 +01:00
name: ${{ env.ARCHIVE_NAME }}.tar.gz
path: ${{ env.ARCHIVE_NAME }}.tar.gz
2024-03-04 20:18:49 +00:00
publish:
name: Publish to crates.io
runs-on: ubuntu-latest
2024-07-26 17:47:53 +01:00
needs: [ build ]
steps:
- uses: actions/checkout@v4
- name: Publish
run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} --allow-dirty --locked
2024-03-04 20:18:49 +00:00
create_release:
name: Create Release
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
2024-07-26 17:47:53 +01:00
needs: [ build, publish ]
2024-03-04 20:18:49 +00:00
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create Release
id: create_release
uses: softprops/action-gh-release@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag_name: ${{ github.ref_name }}
name: ${{ github.ref_name }}
body: ${{ steps.git-cliff.outputs.content }}
draft: true
2024-09-28 23:40:29 +01:00
prerelease: ${{ startsWith(github.ref_name, 'v0') }}
files: artifacts/*