Skip to content

Update test_release.yml #17

Update test_release.yml

Update test_release.yml #17

Workflow file for this run

name: Test Release
# Add a concurrency group incase a tag is created, deleted, and then recreated while a release is in progress.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Only run this workflow when a tag is pushed when the tag starts with "v".
on:
push:
tags:
- "testing_v*"
- "testing_*_v*"
# So we can use the GitHub API to create releases with the run token.
permissions:
contents: write
jobs:
TestRelease:
if: github.event.pull_request.draft == false # Ignore draft PRs
runs-on: ubuntu-latest
defaults:
run:
working-directory: Meddle/Meddle.Plugin/
shell: bash
env:
DALAMUD_HOME: /tmp/dalamud
IsCI: true
steps:
- name: Checkout Repository
uses: actions/checkout@v4
with:
submodules: true # Grab any submodules that may be required
- name: Setup .NET
uses: actions/setup-dotnet@v4
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: |
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
run: dotnet restore
- name: Build plugin in release mode
run: |
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: |
sha512sum latest.zip >> checksums.sha512
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: |
Meddle/Meddle.Plugin/bin/Release/Meddle.Plugin/latest.zip
Meddle/Meddle.Plugin/bin/Release/Meddle.Plugin/checksums.sha512
prerelease: false # Releases cant be marked as prereleases as Dalamud wont be able to find them
append_body: true # Append the release notes to the release body
body_path: .github/release-notices.md # These notes are automatically added to the release body every time.
generate_release_notes: true # Automatically makes a release body from PRs since the last release.
fail_on_unmatched_files: true # If the files arent found, fail the workflow and abort the release.
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: Release Artifacts
path: |
Meddle/Meddle.Plugin/bin/Release/Meddle.Plugin/latest.zip
Meddle/Meddle.Plugin/bin/Release/Meddle.Plugin/checksums.sha512
- name: Update repo.json
run: |
cd ../../
repo_url="$(echo "${{ github.server_url }}/${{ github.repository }}" | sed 's/#/\\#/g')"
echo "Repo URL: $repo_url"
# Update the JSON file using jq
jq --arg version "${{ env.VERSION }}" \
--arg repo_url "$repo_url/releases/download/${{ github.ref_name }}/latest.zip" \
'.[0].TestingAssemblyVersion = $version |
.[0].DownloadLinkTesting = $repo_url' \
repo.json > tmp.json && mv tmp.json repo.json
cat repo.json
git add repo.json
git config --local user.name "github-actions [bot]"
git config --local user.email "[email protected]"
git commit -m "Update repo.json for ${{ github.ref_name }}"
git push origin HEAD:main