Skip to content

Release

Release #2

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Rust
uses: ATiltedTree/setup-rust@v1
with:
rust-version: stable
- name: Build application
run: cargo build --profile dist
- name: Compress artifacts to dsp-calculator-<os>-<tag>.tar.gz
run: tar -czf target/dsp-calculator-${{ matrix.os }}-${{ github.ref }}.tar.gz -C target dist
- name: Archive artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.os }}-release
path: target/dsp-calculator-${{ matrix.os }}-${{ github.ref }}.tar.gz
publish:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
steps:
- name: Download artifacts
uses: actions/download-artifact@v2
with:
path: release
- name: Determine if pre-release
id: prerelease_check
run: |
MAJOR_VERSION=$(echo "${{ github.ref }}" | sed -E 's/^refs\/tags\/v([0-9]+)\..*$/\1/')
if [[ $MAJOR_VERSION == "0" ]]; then
echo "Pre-release"
echo "::set-output name=is_prerelease::--prerelease"
else
echo "Not a pre-release"
echo "::set-output name=is_prerelease:: "
fi
- name: Create Release
id: create_release
run: |
gh release create ${{ github.ref }} \
--title "Release ${{ github.ref }}" \
--generate-notes \
${{ steps.prerelease_check.outputs.is_prerelease }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
id: upload-release-asset
run: |
gh release upload ${{ github.ref }} release/* --clobber
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
cleanup:
runs-on: ubuntu-latest
needs: [publish]
steps:
- name: Clean up artifacts
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const artifacts = await github.actions.listArtifactsForRepo({
per_page: 100
});
const artifactIds = artifacts.data.artifacts
.filter(artifact => artifact.name !== 'release')
.map(artifact => artifact.id);
for (const id of artifactIds) {
await github.actions.deleteArtifact({
artifact_id: id
});
}