From e829a3694dc38572e10823ee83d1a58c1bd65485 Mon Sep 17 00:00:00 2001 From: Passive <20432486+PassiveModding@users.noreply.github.com> Date: Sat, 16 Nov 2024 16:03:24 +1100 Subject: [PATCH] Update test_release.yml --- .github/workflows/test_release.yml | 56 +++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/.github/workflows/test_release.yml b/.github/workflows/test_release.yml index a35e262..cfc05cc 100644 --- a/.github/workflows/test_release.yml +++ b/.github/workflows/test_release.yml @@ -9,7 +9,8 @@ concurrency: on: push: tags: - - "testing_*" + - "testing_v*" + - "testing_*_v*" # So we can use the GitHub API to create releases with the run token. permissions: @@ -37,9 +38,41 @@ jobs: with: dotnet-version: 8.0.x + - name: Extract version and custom path + run: | + tag=${{ github.ref_name }} + + # Check if tag matches the new pattern (testing_{custom_path}_v{version}) + if [[ $tag =~ ^testing_(.+)_v(.+)$ ]]; then + custom_path="${BASH_REMATCH[1]}" + version="${BASH_REMATCH[2]}" + download_path="${BASH_REMATCH[1]}" + # Check if tag matches the original pattern (testing_v{version}) + elif [[ $tag =~ ^testing_v(.+)$ ]]; then + custom_path="latest" + version="${BASH_REMATCH[1]}" + download_path="" + else + echo "Tag format not recognized" + exit 1 + fi + + echo "CUSTOM_PATH=$custom_path" >> $GITHUB_ENV + echo "VERSION=$version" >> $GITHUB_ENV + echo "DOWNLOAD_PATH=$download_path" >> $GITHUB_ENV + echo "Custom Path: $custom_path" + echo "Download Path: $download_path" + echo "Version: $version" + - name: Download Dalamud Library run: | - wget https://goatcorp.github.io/dalamud-distrib/latest.zip -O /tmp/dalamud.zip + download_url="https://goatcorp.github.io/dalamud-distrib" + if [ ! -z "${{ env.DOWNLOAD_PATH }}" ]; then + download_url="$download_url/${{ env.DOWNLOAD_PATH }}" + fi + download_url="$download_url/latest.zip" + echo "Downloading from: $download_url" + wget $download_url -O /tmp/dalamud.zip unzip /tmp/dalamud.zip -d /tmp/dalamud - name: Restore Dependencies @@ -47,10 +80,11 @@ jobs: - name: Build plugin in release mode run: | - version=$(echo ${{ github.ref_name }} | sed 's/testing_v//') - echo "Version: $version" - dotnet build -c Release --no-restore --nologo -o ./bin/Release -p:Version=$version -p:AssemblyVersion=$version -p:FileVersion=$version - + dotnet build -c Release --no-restore --nologo -o ./bin/Release \ + -p:Version=${{ env.VERSION }} \ + -p:AssemblyVersion=${{ env.VERSION }} \ + -p:FileVersion=${{ env.VERSION }} + - name: Generate Checksums working-directory: Meddle/Meddle.Plugin/bin/Release/Meddle.Plugin run: | @@ -79,16 +113,14 @@ jobs: - name: Update repo.json run: | cd ../../ - - release_version=$(echo "${{ github.ref_name }}" | sed 's/^testing_v//') - echo "Release Version: $release_version" + repo_url="$(echo "${{ github.server_url }}/${{ github.repository }}" | sed 's/#/\\#/g')" echo "Repo URL: $repo_url" - + # Update the JSON file using jq - jq --arg release_version "$release_version" \ + jq --arg version "${{ env.VERSION }}" \ --arg repo_url "$repo_url/releases/download/${{ github.ref_name }}/latest.zip" \ - '.[0].TestingAssemblyVersion = $release_version | + '.[0].TestingAssemblyVersion = $version | .[0].DownloadLinkTesting = $repo_url' \ repo.json > tmp.json && mv tmp.json repo.json