From 44e5ec8657224bcb38e24fea2ec9b8257bfc030c Mon Sep 17 00:00:00 2001 From: KlaasWhite Date: Sat, 1 Nov 2025 11:30:30 +0100 Subject: [PATCH 1/3] Testing workflow --- StarMapLoader/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarMapLoader/Program.cs b/StarMapLoader/Program.cs index e47fbe1..ba7ff43 100644 --- a/StarMapLoader/Program.cs +++ b/StarMapLoader/Program.cs @@ -4,7 +4,7 @@ namespace StarMapLoader { internal class Program - { + {//This is for a test static void Main(string[] args) { MainInner().GetAwaiter().GetResult(); From 13bdab5b65cdf593c043af63acf378a9ec764bac Mon Sep 17 00:00:00 2001 From: KlaasWhite Date: Sat, 1 Nov 2025 12:04:07 +0100 Subject: [PATCH 2/3] More github action fixes --- .github/workflows/pr-version-preview.yml | 75 ---------------------- .github/workflows/pr-version.yml | 82 ++++++++++++++++++++++++ .github/workflows/publish-mod-api.yml | 27 +++++++- .github/workflows/release-zip.yml | 10 ++- 4 files changed, 114 insertions(+), 80 deletions(-) delete mode 100644 .github/workflows/pr-version-preview.yml create mode 100644 .github/workflows/pr-version.yml diff --git a/.github/workflows/pr-version-preview.yml b/.github/workflows/pr-version-preview.yml deleted file mode 100644 index 653ce5a..0000000 --- a/.github/workflows/pr-version-preview.yml +++ /dev/null @@ -1,75 +0,0 @@ -name: PR Version Preview - -on: - pull_request: - branches: [main] - -permissions: - pull-requests: write - contents: read - -jobs: - preview: - runs-on: ubuntu-latest - - steps: - # 1️⃣ Checkout full history and all tags - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - fetch-tags: true - - # 2️⃣ Get latest tag and calculate next version - - name: Get latest tag and bump type - id: version - run: | - set +e - git fetch --tags - current=$(git describe --tags --abbrev=0 2>/dev/null) - if [ -z "$current" ]; then - echo "⚠️ No tags found, defaulting to v0.0.0" - current="v0.0.0" - fi - set -e - - # Split into major.minor.patch - IFS='.' read -r major minor patch <<< "${current#v}" - - # Determine bump type from PR labels - LABELS="${{ join(github.event.pull_request.labels.*.name, ' ') }}" - if [[ "$LABELS" == *"major"* ]]; then - ((major++)) - minor=0 - patch=0 - type="major" - elif [[ "$LABELS" == *"minor"* ]]; then - ((minor++)) - patch=0 - type="minor" - else - ((patch++)) - type="patch" - fi - - # Construct next version - next="v$major.$minor.$patch" - echo "next=$next" >> $GITHUB_OUTPUT - echo "type=$type" >> $GITHUB_OUTPUT - - # 3️⃣ Optional debug: show what tags exist and the next version - - name: Debug current tags - run: | - echo "Git tags in this repo:" - git tag -l - echo "Next version: ${{ steps.version.outputs.next }}" - - # 4️⃣ Comment predicted version on PR - - name: Comment version preview - uses: peter-evans/create-or-update-comment@v4 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - 🧩 **Version Preview** - Current latest tag: `${{ steps.version.outputs.next }}` - PR labels: `${{ join(github.event.pull_request.labels.*.name, ', ') }}` - ➡️ **Predicted next version on merge:** **${{ steps.version.outputs.next }}** diff --git a/.github/workflows/pr-version.yml b/.github/workflows/pr-version.yml new file mode 100644 index 0000000..f7df952 --- /dev/null +++ b/.github/workflows/pr-version.yml @@ -0,0 +1,82 @@ +name: PR Version Preview + +on: + pull_request: + branches: [main] + +permissions: + pull-requests: write + contents: read + +jobs: + preview: + runs-on: ubuntu-latest + + steps: + # 1️⃣ Checkout full history and all tags + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + fetch-tags: true + + # 2️⃣ Get latest tag and calculate next version + - name: Get latest tag and bump type + id: version + run: | + # Be defensive and robust: use awk to split version numbers and always quote $GITHUB_OUTPUT + git fetch --tags || true + current=$(git describe --tags --abbrev=0 2>/dev/null || true) + if [ -z "$current" ]; then + echo "No tags found, defaulting to v0.0.0" + current="v0.0.0" + fi + + # Remove leading 'v' then extract parts using awk + ver=${current#v} + major=$(printf "%s" "$ver" | awk -F. '{print $1+0}') + minor=$(printf "%s" "$ver" | awk -F. '{print $2+0}') + patch=$(printf "%s" "$ver" | awk -F. '{print $3+0}') + + # Determine bump type from PR labels (safe interpolation) + LABELS="${{ join(github.event.pull_request.labels.*.name, ' ') }}" + if printf "%s" "$LABELS" | grep -q "major"; then + major=$((major+1)); minor=0; patch=0; type="major" + elif printf "%s" "$LABELS" | grep -q "minor"; then + minor=$((minor+1)); patch=0; type="minor" + else + patch=$((patch+1)); type="patch" + fi + + next="v${major}.${minor}.${patch}" + + # Safely write outputs + if [ -n "$GITHUB_OUTPUT" ]; then + # Write all outputs in one redirect to avoid multiple open/close + { + printf '%s\n' "current=$current" "next=$next" "type=$type" + } >> "$GITHUB_OUTPUT" + else + # Fallback to printing if GITHUB_OUTPUT not available (for local debugging) + echo "current=$current" + echo "next=$next" + echo "type=$type" + fi + + # 3️⃣ Optional debug: show what tags exist and the next version + - name: Debug current tags + run: | + echo "Git tags in this repo:" + git tag -l + echo "Current latest tag: ${{ steps.version.outputs.current }}" + echo "Predicted next version: ${{ steps.version.outputs.next }}" + + # 4️⃣ Comment predicted version on PR + - name: Comment version preview + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + 🧩 **Version Preview** + Current latest tag: `${{ steps.version.outputs.current }}` + PR labels: `${{ join(github.event.pull_request.labels.*.name, ', ') }}` + ➡️ **Predicted next version on merge:** **${{ steps.version.outputs.next }}** diff --git a/.github/workflows/publish-mod-api.yml b/.github/workflows/publish-mod-api.yml index 7a7fbf1..562d72d 100644 --- a/.github/workflows/publish-mod-api.yml +++ b/.github/workflows/publish-mod-api.yml @@ -12,8 +12,8 @@ jobs: contents: read packages: write env: - DOTNET_VERSION: 8.0 - PROJECT: src/MyLibrary/MyLibrary.csproj + DOTNET_VERSION: 9.0 + PROJECT: StarMap.API/StarMap.API.csproj OUTPUT: ./nupkg NUGET_SOURCE: "https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json" @@ -28,11 +28,34 @@ jobs: id: version run: echo "version=${GITHUB_REF_NAME#v}" >> $GITHUB_OUTPUT + - name: Check whether StarMap.API changed since previous tag + id: check + run: | + git fetch --tags + current=${GITHUB_REF_NAME} + # Get previous tag by creation date; empty if none + prev=$(git tag --sort=-creatordate | sed -n '2p' || true) + echo "previous_tag=$prev" >> $GITHUB_OUTPUT + if [ -z "$prev" ]; then + echo "changed=true" >> $GITHUB_OUTPUT + exit 0 + fi + # Show diff between previous tag and this tag + diff=$(git diff --name-only "$prev" "refs/tags/$current") + echo "diff_files=$diff" >> $GITHUB_OUTPUT + if echo "$diff" | grep -qE '^StarMap.API/|^StarMap.API.csproj'; then + echo "changed=true" >> $GITHUB_OUTPUT + else + echo "changed=false" >> $GITHUB_OUTPUT + fi + - name: Pack library + if: steps.check.outputs.changed == 'true' run: dotnet pack ${{ env.PROJECT }} -c Release -o ${{ env.OUTPUT }} /p:PackageVersion=${{ steps.version.outputs.version }} - name: Add GitHub Packages source run: dotnet nuget add source --username "${{ github.actor }}" --password "${{ secrets.GITHUB_TOKEN }}" --store-password-in-clear-text --name github ${{ env.NUGET_SOURCE }} - name: Push to GitHub Packages + if: steps.check.outputs.changed == 'true' run: dotnet nuget push ${{ env.OUTPUT }}/*.nupkg --source github --api-key "${{ secrets.GITHUB_TOKEN }}" --skip-duplicate diff --git a/.github/workflows/release-zip.yml b/.github/workflows/release-zip.yml index 7a2492c..bea327b 100644 --- a/.github/workflows/release-zip.yml +++ b/.github/workflows/release-zip.yml @@ -12,9 +12,11 @@ jobs: permissions: contents: write env: - DOTNET_VERSION: 8.0 - PROJECT: src/MyApp/MyApp.csproj + DOTNET_VERSION: 9.0 + PROJECT: StarMapLoader/StarMapLoader.csproj OUTPUT_PATH: ./publish + # Customize what to exclude from the created ZIP (space-separated patterns) + EXCLUDE: "*.pdb *.xml DummyProgram/*" steps: - uses: actions/checkout@v4 @@ -67,7 +69,9 @@ jobs: - name: Package ZIP run: | cd ${{ env.OUTPUT_PATH }} - zip -r ../../release-${{ steps.version.outputs.new }}.zip . -x "*.pdb" "*.xml" + # EXCLUDE contains space-separated patterns to pass to zip -x + # Use parameter expansion so multiple patterns are honored. + zip -r ../../release-${{ steps.version.outputs.new }}.zip . -x ${EXCLUDE} cd - - name: Create GitHub Release From f9d73318bd45a07866038c8ae8829a6f749dcd96 Mon Sep 17 00:00:00 2001 From: KlaasWhite Date: Sat, 1 Nov 2025 11:30:30 +0100 Subject: [PATCH 3/3] Testing workflow --- StarMapLoader/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/StarMapLoader/Program.cs b/StarMapLoader/Program.cs index e47fbe1..ba7ff43 100644 --- a/StarMapLoader/Program.cs +++ b/StarMapLoader/Program.cs @@ -4,7 +4,7 @@ namespace StarMapLoader { internal class Program - { + {//This is for a test static void Main(string[] args) { MainInner().GetAwaiter().GetResult();