Add gitea runner
This commit is contained in:
144
.gitea/workflows/release-clubpenguin-on-tag.yml
Normal file
144
.gitea/workflows/release-clubpenguin-on-tag.yml
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
name: Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
|
||||||
|
env:
|
||||||
|
PLUGIN_NAME: ClubPenguinSync
|
||||||
|
DOTNET_VERSION: 9.x
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tag-and-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout Club Penguin
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
submodules: true
|
||||||
|
|
||||||
|
- name: Setup .NET 9 SDK
|
||||||
|
uses: actions/setup-dotnet@v4
|
||||||
|
with:
|
||||||
|
dotnet-version: 9.x
|
||||||
|
|
||||||
|
- name: Download Dalamud
|
||||||
|
run: |
|
||||||
|
cd /
|
||||||
|
mkdir -p ~/.xlcore/dalamud/Hooks/dev
|
||||||
|
curl -O https://goatcorp.github.io/dalamud-distrib/stg/latest.zip
|
||||||
|
unzip latest.zip -d ~/.xlcore/dalamud/Hooks/dev
|
||||||
|
|
||||||
|
- name: Build Club Penguin
|
||||||
|
run: |
|
||||||
|
dotnet restore
|
||||||
|
dotnet build --configuration Release --no-restore
|
||||||
|
|
||||||
|
- name: Get version
|
||||||
|
id: package_version
|
||||||
|
uses: KageKirin/get-csproj-version@v0
|
||||||
|
with:
|
||||||
|
file: MareSynchronos/MareSynchronos.csproj
|
||||||
|
|
||||||
|
- name: Display version
|
||||||
|
run: |
|
||||||
|
echo "Version: ${{ steps.package_version.outputs.version }}"
|
||||||
|
|
||||||
|
- name: Prepare Club Penguin
|
||||||
|
run: |
|
||||||
|
mkdir -p output
|
||||||
|
cp MareSynchronos/bin/x64/Release/ClubPenguinSync/latest.zip output/ClubPenguinSync-${{ steps.package_version.outputs.version }}.zip
|
||||||
|
mv MareSynchronos/bin/x64/Release/ClubPenguinSync/latest.zip /repo/download/ClubPenguinSync-${{ steps.package_version.outputs.version }}.zip
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
run: |
|
||||||
|
echo "=== Searching for existing release ${{ steps.package_version.outputs.version }}==="
|
||||||
|
|
||||||
|
release_id=$(curl -s -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
"https://git.drgn.rocks/api/v1/repos/${GITHUB_REPOSITORY}/releases/tags/v${{ steps.package_version.outputs.version }}" | jq -r .id)
|
||||||
|
|
||||||
|
if [ "$release_id" != "null" ]; then
|
||||||
|
echo "=== Deleting existing release ${{ steps.package_version.outputs.version }}==="
|
||||||
|
curl -X DELETE -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
"https://git.drgn.rocks/api/v1/repos/${GITHUB_REPOSITORY}/releases/$release_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== Creating new release ${{ steps.package_version.outputs.version }}==="
|
||||||
|
response=$(
|
||||||
|
curl --fail-with-body -X POST \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
-d '{
|
||||||
|
"tag_name": "v${{ steps.package_version.outputs.version }}",
|
||||||
|
"name": "v${{ steps.package_version.outputs.version }}",
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false
|
||||||
|
}' \
|
||||||
|
"https://git.drgn.rocks/api/v1/repos/${GITHUB_REPOSITORY}/releases"
|
||||||
|
)
|
||||||
|
|
||||||
|
release_id=$(echo "$response" | jq -r .id)
|
||||||
|
echo "release_id=$release_id" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Upload Assets to release
|
||||||
|
run: |
|
||||||
|
curl --fail-with-body -s -X POST \
|
||||||
|
-H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
|
||||||
|
-F "attachment=@output/ClubPenguinSync-${{ steps.package_version.outputs.version }}.zip" \
|
||||||
|
"https://git.drgn.rocks/api/v1/repos/${GITHUB_REPOSITORY}/releases/${{ steps.create_release.outputs.release_id }}/assets"
|
||||||
|
|
||||||
|
- name: Update repo.json with version
|
||||||
|
env:
|
||||||
|
VERSION: ${{ steps.package_version.outputs.version }}
|
||||||
|
run: |
|
||||||
|
set -e
|
||||||
|
|
||||||
|
pluginJsonPath="${PLUGIN_NAME}/bin/x64/Release/${PLUGIN_NAME}.json"
|
||||||
|
repoJsonPath="/repo/repo.json"
|
||||||
|
version="${VERSION}"
|
||||||
|
downloadUrl="https://clubpenguin.drgn.rocks/download/ClubPenguinSync-${{ steps.package_version.outputs.version }}.zip"
|
||||||
|
|
||||||
|
# Read plugin JSON
|
||||||
|
pluginJson=$(cat "$pluginJsonPath")
|
||||||
|
internalName=$(jq -r '.InternalName' <<< "$pluginJson")
|
||||||
|
dalamudApiLevel=$(jq -r '.DalamudApiLevel' <<< "$pluginJson")
|
||||||
|
|
||||||
|
# Read repo JSON (force array if not already)
|
||||||
|
repoJsonRaw=$(cat "$repoJsonPath")
|
||||||
|
if echo "$repoJsonRaw" | jq 'type' | grep -q '"array"'; then
|
||||||
|
repoJson="$repoJsonRaw"
|
||||||
|
else
|
||||||
|
repoJson="[$repoJsonRaw]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Update matching plugin entry
|
||||||
|
updatedRepoJson=$(jq \
|
||||||
|
--arg internalName "$internalName" \
|
||||||
|
--arg dalamudApiLevel "$dalamudApiLevel" \
|
||||||
|
--arg version "$version" \
|
||||||
|
--arg downloadUrl "$downloadUrl" \
|
||||||
|
'
|
||||||
|
map(
|
||||||
|
if .InternalName == $internalName
|
||||||
|
then
|
||||||
|
.DalamudApiLevel = $dalamudApiLevel
|
||||||
|
| .AssemblyVersion = $version
|
||||||
|
| .DownloadLinkInstall = $downloadUrl
|
||||||
|
| .DownloadLinkTesting = $downloadUrl
|
||||||
|
| .DownloadLinkUpdate = $downloadUrl
|
||||||
|
else
|
||||||
|
.
|
||||||
|
end
|
||||||
|
)
|
||||||
|
' <<< "$repoJson")
|
||||||
|
|
||||||
|
# Write back to file
|
||||||
|
echo "$updatedRepoJson" > "$repoJsonPath"
|
||||||
|
# Output the content of the file
|
||||||
|
cat "$repoJsonPath"
|
||||||
Reference in New Issue
Block a user