Skip to content

Commit

Permalink
chore: create release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jolexxa committed Apr 25, 2024
1 parent 42cda73 commit cfc8201
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 98 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/auto_release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# You can disable this action by setting the DISABLE_AUTO_RELEASE repository
# variable to true.

name: 🦾 Auto-Release
name: '🦾 Auto-Release'
on:
workflow_run:
workflows: ["🚥 Tests"]
Expand All @@ -31,7 +31,11 @@ jobs:
should_release: ${{ steps.release.outputs.should_release }}
steps:
- name: 🧾 Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BASIC }}
lfs: true
submodules: 'recursive'

- name: 🧑‍🔬 Check Test Results
id: tests
Expand Down Expand Up @@ -65,11 +69,12 @@ jobs:
echo "✋ Not creating a release."
fi
release:
uses: './.github/workflows/publish.yaml'
trigger_release:
uses: './.github/workflows/release.yaml'
needs: auto_release
if: needs.auto_release.outputs.should_release == 'true'
secrets:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
GH_BASIC: ${{ secrets.GH_BASIC }}
with:
bump: patch
94 changes: 0 additions & 94 deletions .github/workflows/publish.yaml

This file was deleted.

88 changes: 88 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
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'

- name: 🔎 Read Current Project Verson
uses: KageKirin/[email protected]
id: current-version
with:
file: Chickensoft.GoDotCollections/Chickensoft.GoDotCollections.csproj
xpath: /Project/PropertyGroup/Version

- name: 🖨 Print Current Version
run: |
echo "Current Version: ${{ steps.current-version.outputs.version }}"
- name: 🧮 Compute Next Version
uses: chickensoft-games/next-godot-csproj-version@v1
id: next-version
with:
project-version: ${{ steps.current-version.outputs.version }}
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

- 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
6 changes: 6 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"sdk": {
"rollForward": "major",
"version": "7.0.306"
}
}

0 comments on commit cfc8201

Please sign in to comment.