name: 'Release' on: # 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: "Personal access token (PAT) for GitHub" 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 env: DOTNET_CLI_TELEMETRY_OPTOUT: true DOTNET_NOLOGO: true steps: - name: Checkout uses: actions/checkout@v6 with: token: ${{ secrets.GH_BASIC }} lfs: true submodules: 'recursive' fetch-depth: 0 # So we can get all tags. - name: Read Current Project Version id: current-version uses: WyriHaximus/github-action-get-previous-tag@v2 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: ${{ inputs.bump }} - uses: actions/setup-dotnet@v5 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: GodotHelper/GodotHelper.csproj # - name: Build # working-directory: GodotHelper # run: dotnet build -c Release # - name: Get Package Path # id: package-path # run: | # package=$(find ./GodotHelper/nupkg -name "*.nupkg") # echo "package=$package" >> "$GITHUB_OUTPUT" # echo "Found package: $package" # echo "${{ steps.package-path.outputs.package }}" # # - name: Create Release # # run: | # # version="${{ steps.next-version.outputs.version }}" # # curl -X POST "http://192.168.1.4:3000/api/packages/Ronnie/GodotHelpers/releases" \ # # -H "Authorization: token ${{ secrets.GH_BASIC }}" \ # # -H "Content-Type: application/json" \ # # -d "{ # # \"tag_name\": \"$version\", # # \"name\": \"v$version\", # # \"body\": \"Auto release $version\" # # }" # - name: Publish to Nuget # run: | # dotnet nuget push "${{ steps.package-path.outputs.package }}" \ # --source "gitea:3000/api/packages/Ronnie/nuget/index.json" \ # --allow-insecure-connections \ # --api-key "${{ secrets.NUGET_KEY }}" \ # --skip-duplicate - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: 10.0.x - name: Restore run: dotnet restore - name: Calculate Version id: version run: | TAG=$(git describe --tags --abbrev=0) COMMITS=$(git rev-list $TAG..HEAD --count) BASE=${TAG#v} IFS='.' read MAJOR MINOR PATCH <<< "$BASE" NEW_PATCH=$((PATCH + COMMITS)) VERSION="$MAJOR.$MINOR.$NEW_PATCH" echo "VERSION=$VERSION" >> $GITHUB_OUTPUT - name: Build run: dotnet build -c Release - name: Pack run: | dotnet pack \ -p:PackageVersion=${{ steps.version.outputs.VERSION }} \ -c Release - name: Publish run: | dotnet nuget push ./bin/Release/*.nupkg \ --source "http://192.168.1.4:3000/api/packages/Ronnie/nuget/index.json" \ --allow-insecure-connections \ --api-key "${{ secrets.NUGET_KEY }}" \ --skip-duplicate