Merge pull request #22 from Michaelvsk/fix/release_wf #26
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 | |
concurrency: ${{ github.ref }} | |
on: | |
workflow_dispatch: | |
push: | |
branches: [ main ] | |
jobs: | |
versioning: | |
name: Bump Version | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.versioning.outputs.version }} | |
commit: ${{ steps.versioning.outputs.commit }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.GH_ADMIN_TOKEN }} | |
- name: Setup GIT | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "$GITHUB_ACTOR" | |
# Tool to compute version based on Github PR labels | |
- name: Install auto versioning | |
run: > | |
npm install --global | |
[email protected] | |
@auto-it/[email protected] | |
@auto-it/[email protected] | |
@auto-it/[email protected] | |
@auto-it/[email protected] | |
# dotnet version relies on .NET Core 2.1 (TODO maybe fork project dotnet version as .NET 2.1 reached EOL) | |
- uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: '2.1.x' | |
# Versioning tool for dotnet projects similar to 'npm version' | |
- name: install DotNetVersioning | |
run: dotnet tool install --global DotNetVersioning.Tool | |
# CLI XPath parser to extract final AssemblyVersion from csproj file | |
- name: Install xmlstarlet | |
run: sudo apt-get install -y xmlstarlet | |
- id: versioning | |
name: Versioning | |
run: | | |
if VERSION=$(auto version 2>&1); then | |
echo "Calculated version bump is ${VERSION}" | |
else | |
echo "auto version failed. Error: ${VERSION}" | |
exit 1 | |
fi | |
if [ ! -z "$VERSION" ]; then | |
dotnet version $VERSION | |
if VERSION_NO=$(xmlstarlet sel -t -m '/Project/PropertyGroup/AssemblyVersion' -v . < ./GameDb/GameDb.csproj 2>&1); then | |
echo "Extracted version number is: ${VERSION_NO}" | |
echo "git status:" | |
git status | |
auto changelog --no-git-commit | |
git commit -a -m "chore(release): Release version ${VERSION_NO} [skip ci]" | |
echo "version=${VERSION_NO}" >> "$GITHUB_OUTPUT" | |
echo "commit=`git rev-parse --verify HEAD`" >> "$GITHUB_OUTPUT" | |
git push | |
else | |
echo "Extracting version from csproj file failed. Error: ${VERSION_NO}" | |
exit 1 | |
fi | |
else | |
echo 'Not bumping version, skipping release' | |
fi | |
env: | |
GITHUB_TOKEN: ${{secrets.GH_ADMIN_TOKEN}} | |
build: | |
uses: ./.github/workflows/wf-build.yaml | |
needs: versioning | |
name: Build .NET MAUI App | |
with: | |
append-build-number: false | |
ref: ${{ needs.versioning.outputs.commit }} | |
secrets: | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
release: | |
name: Create Release | |
needs: [versioning, build] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
path: repo | |
ref: ${{ needs.versioning.outputs.commit }} | |
token: ${{ secrets.GH_ADMIN_TOKEN }} | |
- name: Setup GIT | |
working-directory: ./repo | |
run: | | |
git config user.email "[email protected]" | |
git config user.name "$GITHUB_ACTOR" | |
# Compute version based on Github PR labels | |
- name: Install auto versioning | |
run: > | |
npm install --global | |
[email protected] | |
@auto-it/[email protected] | |
@auto-it/[email protected] | |
@auto-it/[email protected] | |
@auto-it/[email protected] | |
- uses: actions/download-artifact@v3 | |
with: | |
name: android-build | |
path: android-artifact | |
- uses: actions/download-artifact@v3 | |
with: | |
name: windows-build | |
path: windows-artifact | |
- name: Zip Builds | |
run: | | |
zip -r -9 windows-build.zip windows-artifact | |
zip -r -9 android-build.zip android-artifact | |
- name: Create Release | |
working-directory: ./repo | |
run: auto shipit --only-graduate-with-release-label --no-changelog | |
env: | |
GH_TOKEN: ${{secrets.GH_ADMIN_TOKEN}} |