diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..cbb09a6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,142 @@ +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 Release + 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}"