Rework release workflow #11
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: Release | |
on: | |
push: | |
branches: | |
- workflow_release | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+' | |
- 'v[0-9]+.[0-9]+.[0-9]+-alpha' | |
- 'v[0-9]+.[0-9]+.[0-9]+-beta' | |
jobs: | |
release: | |
name: release | |
runs-on: ubuntu-latest | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write | |
id-token: write | |
contents: write | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '6.0.x' | |
- name: Install documentation tool | |
run: dotnet tool update -g docfx | |
shell: bash | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Gather release info | |
id: info | |
run: | | |
ref_name='${{ github.ref_name }}' | |
echo "ref_name: $ref_name" | |
# is this a test release, or a real release? | |
if [[ "$ref_name" == 'workflow_release' ]]; then | |
version='v0.0.0-test' | |
else | |
version="$ref_name" | |
fi | |
echo "version: $version" | |
echo "version=$version" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Create staging dir | |
id: staging | |
run: | | |
staging='Mech3DotNet-${{ steps.info.outputs.version }}' | |
mkdir "$staging" | |
cp {README.md,LICENSE} "$staging/" | |
echo "staging=$staging" >> $GITHUB_OUTPUT | |
shell: bash | |
- name: Run dotnet restore | |
run: dotnet restore | |
shell: bash | |
- name: Run dotnet build | |
id: build | |
run: > | |
dotnet build | |
--no-incremental | |
--no-restore | |
--configuration 'Release' | |
--output '${{ steps.staging.outputs.staging }}' | |
Mech3DotNet | |
shell: bash | |
- name: Package archives | |
id: package | |
run: | | |
mkdir 'assets' | |
tar czvf 'assets/${{ steps.staging.outputs.staging }}.tar.gz' '${{ steps.staging.outputs.staging }}' | |
7z a 'assets/${{ steps.staging.outputs.staging }}.zip' '${{ steps.staging.outputs.staging }}' | |
ls -1R assets/* | |
shell: bash | |
- name: Generate documentation | |
run: docfx Docs/docfx.json | |
shell: bash | |
- name: Upload pages artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
path: Docs/_site | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
- name: Create GitHub release | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
version='${{ steps.info.outputs.version }}' | |
echo "version: $version" | |
# empty arguments | |
set -- | |
# is this a test release, or a real release? | |
if [[ "$version" == 'v0.0.0-test' ]]; then | |
set -- "$@" --target '${{ github.sha }}' | |
fi | |
# is this a pre-release (-rc*, -alpha, -beta, -test)? | |
if [[ "$version" == *"-"* ]]; then | |
set -- "$@" --prerelease | |
fi | |
date=$(env TZ=':America/Los_Angeles' date +'%Y-%m-%d') | |
echo "date: $date" | |
echo "args: $@" | |
set -x | |
gh release create \ | |
"$version" \ | |
assets/* \ | |
--title "$version ($date)" \ | |
--draft \ | |
--repo '${{ github.repository }}' \ | |
"$@" | |
shell: bash |