208 lines
7.2 KiB
YAML
208 lines
7.2 KiB
YAML
name: Release Pipeline
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
bump-version:
|
|
name: Bump Version & Create Tag
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.bump.outputs.version }}
|
|
tag: ${{ steps.bump.outputs.tag }}
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Compute Next Version and Tag
|
|
id: bump
|
|
run: |
|
|
git fetch --tags
|
|
LATEST_TAG=$(git tag -l "v*" | sort -V | tail -n 1)
|
|
|
|
if [ -z "$LATEST_TAG" ]; then
|
|
NEXT_VERSION="1.0.0"
|
|
else
|
|
CLEAN_VERSION="${LATEST_TAG#v}"
|
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$CLEAN_VERSION"
|
|
PATCH=$((PATCH + 1))
|
|
NEXT_VERSION="${MAJOR}.${MINOR}.${PATCH}"
|
|
fi
|
|
|
|
NEXT_TAG="v${NEXT_VERSION}"
|
|
echo "Latest tag found: ${LATEST_TAG:-none}"
|
|
echo "Calculated next release version: ${NEXT_VERSION}"
|
|
echo "Calculated next release tag: ${NEXT_TAG}"
|
|
|
|
git config user.name "github-actions[bot]"
|
|
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
git tag "${NEXT_TAG}"
|
|
git push origin "${NEXT_TAG}"
|
|
|
|
echo "version=${NEXT_VERSION}" >> "$GITHUB_OUTPUT"
|
|
echo "tag=${NEXT_TAG}" >> "$GITHUB_OUTPUT"
|
|
|
|
package:
|
|
name: Package ${{ matrix.os-name }}
|
|
needs: bump-version
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- os: macos-latest
|
|
os-name: macOS (DMG)
|
|
artifact-name: macos-dmg
|
|
artifact-path: composeApp/build/compose/binaries/main/dmg/*.dmg
|
|
gradle-task: ":composeApp:packageDmg"
|
|
- os: windows-latest
|
|
os-name: Windows (MSI)
|
|
artifact-name: windows-msi
|
|
artifact-path: composeApp/build/compose/binaries/main/msi/*.msi
|
|
gradle-task: ":composeApp:packageMsi"
|
|
- os: ubuntu-latest
|
|
os-name: Linux (DEB)
|
|
artifact-name: linux-deb
|
|
artifact-path: composeApp/build/compose/binaries/main/deb/*.deb
|
|
gradle-task: ":composeApp:packageDeb"
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK 17
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: 'temurin'
|
|
java-version: '17'
|
|
|
|
- name: Setup Gradle
|
|
uses: gradle/actions/setup-gradle@v4
|
|
|
|
- name: Build Package (${{ matrix.os-name }})
|
|
shell: bash
|
|
run: |
|
|
./gradlew ${{ matrix.gradle-task }} -PappVersion=${{ needs.bump-version.outputs.version }}
|
|
|
|
- name: Upload Artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.artifact-name }}
|
|
path: ${{ matrix.artifact-path }}
|
|
if-no-files-found: error
|
|
|
|
create-release:
|
|
name: Create GitHub & Forgejo Releases
|
|
needs:
|
|
- bump-version
|
|
- package
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download all packaged artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: release-assets
|
|
|
|
- name: Publish GitHub Release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
RELEASE_TAG: ${{ needs.bump-version.outputs.tag }}
|
|
RELEASE_VERSION: ${{ needs.bump-version.outputs.version }}
|
|
run: |
|
|
mkdir -p dist
|
|
find release-assets -type f \( -name "*.dmg" -o -name "*.msi" -o -name "*.deb" \) -exec cp {} dist/ \;
|
|
|
|
echo "Files prepared for release:"
|
|
ls -lh dist/
|
|
|
|
RELEASE_BODY="### WoW Backup ${RELEASE_TAG}
|
|
|
|
Automated release build for **WoW Backup v${RELEASE_VERSION}**.
|
|
|
|
#### Available Packages
|
|
- **macOS**: \`.dmg\` installer (Apple Silicon & Intel)
|
|
- **Windows**: \`.msi\` Windows Installer
|
|
- **Linux**: \`.deb\` package (Debian / Ubuntu)
|
|
|
|
---
|
|
For detailed setup and installation notes, please refer to [INSTALL.md](https://github.com/${{ github.repository }}/blob/${RELEASE_TAG}/INSTALL.md)."
|
|
|
|
gh release create "${RELEASE_TAG}" dist/* \
|
|
--title "WoW Backup ${RELEASE_TAG}" \
|
|
--notes "${RELEASE_BODY}"
|
|
|
|
- name: Publish Forgejo Release
|
|
env:
|
|
FORGEJO_PAT: ${{ secrets.FORGEJO_PAT }}
|
|
RELEASE_TAG: ${{ needs.bump-version.outputs.tag }}
|
|
RELEASE_VERSION: ${{ needs.bump-version.outputs.version }}
|
|
run: |
|
|
RELEASE_BODY="### WoW Backup ${RELEASE_TAG}
|
|
|
|
Automated release build for **WoW Backup v${RELEASE_VERSION}**.
|
|
|
|
#### Available Packages
|
|
- **macOS**: \`.dmg\` installer (Apple Silicon & Intel)
|
|
- **Windows**: \`.msi\` Windows Installer
|
|
- **Linux (Experimental)**: \`.deb\` package (Debian / Ubuntu)
|
|
|
|
---
|
|
For detailed setup and installation notes, please refer to [INSTALL.md](https://git.asarius.site/rukira/wow-backup/src/tag/${RELEASE_TAG}/INSTALL.md)."
|
|
|
|
echo "Publishing release ${RELEASE_TAG} to Forgejo (git.asarius.site)..."
|
|
|
|
PAYLOAD=$(jq -n \
|
|
--arg tag "$RELEASE_TAG" \
|
|
--arg name "WoW Backup ${RELEASE_TAG}" \
|
|
--arg body "$RELEASE_BODY" \
|
|
'{tag_name: $tag, name: $name, body: $body, draft: false, prerelease: false}')
|
|
|
|
CREATE_RESPONSE=$(curl -sS -X POST \
|
|
"https://git.asarius.site/api/v1/repos/rukira/wow-backup/releases" \
|
|
-H "Authorization: token ${FORGEJO_PAT}" \
|
|
-H "Content-Type: application/json" \
|
|
-H "Accept: application/json" \
|
|
-d "$PAYLOAD" || true)
|
|
|
|
RELEASE_ID=$(echo "$CREATE_RESPONSE" | jq -r '.id // empty')
|
|
|
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
|
echo "Release creation did not return an ID, checking if release already exists for tag ${RELEASE_TAG}..."
|
|
GET_RESPONSE=$(curl -sS -X GET \
|
|
"https://git.asarius.site/api/v1/repos/rukira/wow-backup/releases/tags/${RELEASE_TAG}" \
|
|
-H "Authorization: token ${FORGEJO_PAT}" \
|
|
-H "Accept: application/json" || true)
|
|
RELEASE_ID=$(echo "$GET_RESPONSE" | jq -r '.id // empty')
|
|
fi
|
|
|
|
if [ -z "$RELEASE_ID" ] || [ "$RELEASE_ID" = "null" ]; then
|
|
echo "::error::Failed to create or find Forgejo release."
|
|
echo "Response: $CREATE_RESPONSE"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Forgejo Release ID: ${RELEASE_ID}"
|
|
|
|
for file in dist/*; do
|
|
[ -f "$file" ] || continue
|
|
filename=$(basename "$file")
|
|
echo "Uploading asset ${filename} to Forgejo release ${RELEASE_ID}..."
|
|
curl -sS --fail-with-body -X POST \
|
|
"https://git.asarius.site/api/v1/repos/rukira/wow-backup/releases/${RELEASE_ID}/assets" \
|
|
--url-query "name=${filename}" \
|
|
-H "Authorization: token ${FORGEJO_PAT}" \
|
|
-H "Accept: application/json" \
|
|
-F "attachment=@${file}"
|
|
done
|
|
|
|
echo "Forgejo release published successfully."
|