fix: use latest tag for version to work when running manually #14
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: | |
# Make a release whenever we push a version tag. | |
push: | |
tags: | |
- 'v*' | |
# Make a release whenever the developer wants. | |
workflow_dispatch: | |
inputs: | |
bump: | |
type: string | |
description: "major, minor, or patch" | |
required: true | |
default: "patch" | |
# Make a release whenever we're told to by another workflow. | |
workflow_call: | |
secrets: | |
NUGET_API_KEY: | |
description: "API key for Nuget" | |
required: true | |
GH_BASIC: | |
description: "PAT" | |
required: true | |
# Input unifies with the workflow dispatch since it's identical. | |
inputs: | |
bump: | |
type: string | |
description: "major, minor, or patch" | |
required: true | |
default: "patch" | |
jobs: | |
release: | |
name: '📦 Release' | |
runs-on: ubuntu-latest | |
steps: | |
- name: 🧾 Checkout | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GH_BASIC }} | |
lfs: true | |
submodules: 'recursive' | |
fetch-depth: 0 # So we can get all tags. | |
- name: 🔎 Read Current Project Verson | |
id: current-version | |
uses: WyriHaximus/github-action-get-previous-tag@v1 | |
with: | |
fallback: "0.0.0-devbuild" | |
- name: 🖨 Print Current Version | |
run: | | |
echo "Current Version: ${{ steps.current-version.outputs.tag }}" | |
- name: 🧮 Compute Next Version | |
uses: chickensoft-games/next-godot-csproj-version@v1 | |
id: next-version | |
with: | |
project-version: ${{ steps.current-version.outputs.tag }} | |
godot-version: global.json | |
bump: ${{ github.event.inputs.bump }} | |
- uses: actions/setup-dotnet@v3 | |
name: 💽 Setup .NET SDK | |
with: | |
# Use the .NET SDK from global.json in the root of the repository. | |
global-json-file: global.json | |
# Write version to file so .NET will build correct version. | |
- name: 📝 Write Version to File | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "0.0.0-devbuild" | |
replace: ${{ steps.next-version.outputs.version }} | |
regex: false | |
include: Chickensoft.GoDotCollections/Chickensoft.GoDotCollections.csproj | |
- name: 📦 Build | |
run: dotnet build Chickensoft.GoDotCollections/Chickensoft.GoDotCollections.csproj -c Release | |
- name: 🔎 Get Package Path | |
id: package-path | |
run: | | |
package=$(find ./Chickensoft.GoDotCollections/nupkg -name "*.nupkg") | |
echo "package=$package" >> "$GITHUB_OUTPUT" | |
echo "📦 Found package: $package" | |
- name: ✨ Create Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_BASIC }} | |
run: | | |
version="v${{ steps.next-version.outputs.version }}" | |
gh release create --title "$version" --generate-notes "$version" \ | |
"${{ steps.package-path.outputs.package }}" | |
- name: 🛜 Publish to Nuget | |
run: | | |
dotnet nuget push "${{ steps.package-path.outputs.package }}" --api-key "${{ secrets.NUGET_API_KEY }}" --source "https://api.nuget.org/v3/index.json" --skip-duplicate |