Skip to content

Commit

Permalink
Merge pull request #3 from chickensoft-games/chore/updates
Browse files Browse the repository at this point in the history
chore: qol updates
  • Loading branch information
jolexxa authored Apr 25, 2024
2 parents ca7c08f + cfc8201 commit 10f2788
Show file tree
Hide file tree
Showing 6 changed files with 150 additions and 127 deletions.
63 changes: 43 additions & 20 deletions .github/workflows/auto_release.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# This workflow automatically looks for pushes to main whose last commit
# message contains the phrase "chore(deps): update all dependencies".
# If it finds such a commit, and the testing workflow has passed, it will
# automatically release a new version of the project by running the publish
# workflow.
# This workflow will run whenever tests finish running. If tests pass, it will
# look at the last commit message to see if it contains the phrase
# "chore(deps): update all dependencies".
#
# If it finds a commit with that phrase, and the testing workflow has passed,
# it will automatically release a new version of the project by running the
# publish workflow.
#
# The commit message phrase above is always used by renovatebot when opening
# PR's to update dependencies. If you have renovatebot enabled and set to
# automatically merge in dependency updates, this can automatically release and
# publish the updated version of the project.
#
# 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 @@ -19,39 +24,57 @@ on:
- completed

jobs:
check_if_should_release:
auto_release:
name: 🦾 Auto-Release
runs-on: ubuntu-latest
outputs:
should_release: ${{ steps.tests.outputs.passed && steps.release.outputs.changed }}
should_release: ${{ steps.release.outputs.should_release }}
steps:
- name: 🧾 Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_BASIC }}
lfs: true
submodules: 'recursive'

- name: 🧐 Check Tests Workflow
- name: 🧑‍🔬 Check Test Results
id: tests
run:
run: |
echo "passed=${{ github.event.workflow_run.conclusion == 'success' }}" >> "$GITHUB_OUTPUT"
- name: 📄 Determine If Dependencies Have Changed
id: release
if: ${{ steps.tests.outputs.passed == 'true' }}
- name: 📄 Check If Dependencies Changed
id: deps
run: |
message=$(git log -1 --pretty=%B)
if [[ $message == *"chore(deps): update all dependencies"* ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Dependencies updated: automatically releasing!"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Dependencies not updated: skipping release."
fi
release:
uses: './.github/workflows/publish.yaml'
needs: check_if_should_release
if: ${{ needs.check_if_should_release.outputs.should_release == 'true' }}
- name: 📝 Check Release Status
id: release
run: |
echo "Tests passed: ${{ steps.tests.outputs.passed }}"
echo "Dependencies changed: ${{ steps.deps.outputs.changed }}"
disable_auto_release='${{ vars.DISABLE_AUTO_RELEASE }}'
echo "DISABLE_AUTO_RELEASE=$disable_auto_release"
if [[ ${{ steps.tests.outputs.passed }} == "true" && ${{ steps.deps.outputs.changed }} == "true" && $disable_auto_release != "true" ]]; then
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "🦾 Creating a release!"
else
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "✋ Not creating a release."
fi
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: 3 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"[csharp]": {
"editor.codeActionsOnSave": {
"source.addMissingImports": true,
"source.fixAll": true,
"source.organizeImports": true
"source.addMissingImports": "explicit",
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
},
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
Expand Down
20 changes: 10 additions & 10 deletions Chickensoft.GoDotCollections/src/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,31 @@ public TValue? this[int index] {
/// <summary>Map enumerator.</summary>
public IDictionaryEnumerator GetEnumerator() => _collection.GetEnumerator();
/// <summary>Insert a key and value at the specified index.</summary>
/// <param name="index"></param>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="index">Index to insert to.</param>
/// <param name="key">Key.</param>
/// <param name="value">Value.</param>
public void Insert(int index, TKey key, TValue value)
=> _collection.Insert(index, key, value);
/// <summary>Remove a key/value pair at the specified index.</summary>
/// <param name="index"></param>
/// <param name="index">Index to remove from.</param>
public void RemoveAt(int index) => _collection.RemoveAt(index);
/// <summary>True if the given key is in the map.</summary>
/// <param name="key"></param>
/// <param name="key">Key.</param>
public bool Contains(TKey key) => _collection.Contains(key);
/// <summary>Adds or updates a key/value pair to the map.</summary>
/// <param name="key"></param>
/// <param name="value"></param>
/// <param name="key">Key.</param>
/// <param name="value">Value.</param>
public void Add(TKey key, TValue value) => _collection.Add(key, value);
/// <summary>Removes all entries from the map.</summary>
public void Clear() => _collection.Clear();
/// <summary>Remove a key/value pair from the map.</summary>
/// <param name="key"></param>
/// <param name="key">Key.</param>
public void Remove(TKey key) => _collection.Remove(key);
/// <summary>
/// Copy the map to an array, beginning at the given index.
/// </summary>
/// <param name="array"></param>
/// <param name="index"></param>
/// <param name="array">Destination array.</param>
/// <param name="index">Start index.</param>
public void CopyTo(Array array, int index)
=> _collection.CopyTo(array, index);
}
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 10f2788

Please sign in to comment.