Try to fix vars #25
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: .NET Windows Release 🚀 | |
on: | |
push: | |
branches: | |
- master | |
workflow_dispatch: # Permite execução manual | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
outputs: | |
previous_tag: ${{ steps.tag.outputs.previous_tag }} | |
current_tag: ${{ steps.tag.outputs.current_tag }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # Pega todas as tags existentes | |
- name: Setup .NET | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 8.0.x | |
- name: Build Project | |
run: dotnet build --configuration Release | |
- name: Publish Artifacts | |
run: | | |
mkdir -p release | |
dotnet publish ./FactorioSaveGameEnableAchievements/FactorioSaveGameEnableAchievements.csproj -c Release -o release | |
- name: Create Zip Archive | |
run: zip -r release.zip release/ | |
- name: Set Git Identity | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Generate Version Tag | |
id: tag | |
run: | | |
GAME_VERSION="2.0.28" | |
LATEST_TAG=$(git tag --sort=-v:refname | grep "^${GAME_VERSION}-" | head -n 1) | |
if [ -z "$LATEST_TAG" ]; then | |
NEW_TAG="${GAME_VERSION}-1.0" | |
echo "No previous tag found. Creating initial tag: $NEW_TAG" | |
git tag -a $NEW_TAG -m "Initial Release $NEW_TAG" | |
git push origin $NEW_TAG | |
else | |
LAST_VERSION=$(echo $LATEST_TAG | awk -F '-' '{print $2}') | |
NEW_VERSION=$(echo "$LAST_VERSION + 0.1" | bc) | |
NEW_TAG="${GAME_VERSION}-$(printf %.1f $NEW_VERSION)" | |
fi | |
echo "previous_tag=$LATEST_TAG" >> $GITHUB_ENV | |
echo "current_tag=$NEW_TAG" >> $GITHUB_ENV | |
echo "::set-output name=previous_tag::$LATEST_TAG" | |
echo "::set-output name=current_tag::$NEW_TAG" | |
- name: Draft Release | |
id: draft_release | |
uses: release-drafter/release-drafter@v5 | |
with: | |
config-name: release-drafter.yml | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
PREVIOUS_TAG: ${{ steps.tag.outputs.previous_tag }} | |
CURRENT_TAG: ${{ steps.tag.outputs.current_tag }} | |
- name: Publish Release | |
uses: ncipollo/release-action@v1 | |
with: | |
tag: ${{ env.current_tag }} | |
name: "Release ${{ env.current_tag }}" | |
body: ${{ steps.draft_release.outputs.body }} | |
artifacts: "release.zip" | |
draft: false | |
prerelease: false |