diff --git a/.github/workflows/prepare-release.yml b/.github/workflows/prepare-release.yml index 667791c19..356a0832d 100644 --- a/.github/workflows/prepare-release.yml +++ b/.github/workflows/prepare-release.yml @@ -20,6 +20,11 @@ jobs: distribution: 'adopt' java-version: 21 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Gradle caching uses: actions/cache@v5 with: @@ -30,59 +35,25 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Package Windows ".msi" distribution - run: ./gradlew :desktop:packageReleaseMsi + - name: Package Windows distributions + run: > + ./gradlew + :desktop:packageReleaseMsi + :desktop:packageReleaseExe + :desktop:packageReleasePortable + :desktop:packageReleaseAppX - - name: Rename MSI Artifact - shell: cmd + - name: Stage Windows artifacts + shell: pwsh run: | - setlocal enabledelayedexpansion - - set "pattern=hammer-*.msi" - set "newName=hammer.msi" - set "foundFile=" - - for /r %%i in (%pattern%) do ( - set "foundFile=%%i" - ) - - if defined foundFile ( - echo Renaming !foundFile! to %newName% - ren "!foundFile!" "%newName%" - ) else ( - echo No file matching pattern found. - ) - - endlocal - - echo Successfully renamed file to "hammer.msi" - - - name: Package Windows ".exe" distribution - run: ./gradlew :desktop:packageReleaseExe - - - name: Rename EXE Artifact - shell: cmd - run: | - setlocal enabledelayedexpansion - - set "pattern=hammer-*.exe" - set "newName=hammer.exe" - set "foundFile=" - - for /r %%i in (%pattern%) do ( - set "foundFile=%%i" - ) - - if defined foundFile ( - echo Renaming !foundFile! to %newName% - ren "!foundFile!" "%newName%" - ) else ( - echo No file matching pattern found. - ) - - endlocal - - echo Successfully renamed file to "hammer.exe" + $stage = "$env:GITHUB_WORKSPACE\release-artifacts" + New-Item -ItemType Directory -Force -Path $stage | Out-Null + $root = "desktop\build\compose\binaries\main-release" + Get-ChildItem -Path "$root\msi" -Filter *.msi -Recurse | Select-Object -First 1 | Copy-Item -Destination "$stage\hammer.msi" + Get-ChildItem -Path "$root\exe" -Filter *.exe -Recurse | Select-Object -First 1 | Copy-Item -Destination "$stage\hammer.exe" + Get-ChildItem -Path "$root\portable" -Filter *.exe -Recurse | Select-Object -First 1 | Copy-Item -Destination "$stage\hammer-portable.exe" + Get-ChildItem -Path "$root\appx" -Include *.appx,*.msix -Recurse | Select-Object -First 1 | Copy-Item -Destination "$stage\hammer.appx" + Get-ChildItem $stage - name: Create Release uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0 @@ -93,10 +64,12 @@ jobs: prerelease: true artifactErrorsFailBuild: true allowUpdates: true - artifacts: "${{ github.workspace }}\\desktop\\build\\installers\\main-release\\msi\\hammer.msi,${{ github.workspace }}\\desktop\\build\\installers\\main-release\\exe\\hammer.exe" + artifacts: "${{ github.workspace }}\\release-artifacts\\hammer.msi,${{ github.workspace }}\\release-artifacts\\hammer.exe,${{ github.workspace }}\\release-artifacts\\hammer-portable.exe,${{ github.workspace }}\\release-artifacts\\hammer.appx" linux: runs-on: ubuntu-latest + permissions: + contents: write steps: - name: Checkout code uses: actions/checkout@v6 @@ -107,6 +80,19 @@ jobs: distribution: 'jetbrains' java-version: 21 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + + - name: Install Linux packaging dependencies + run: | + sudo apt-get update + sudo apt-get install -y rpm fakeroot snapd flatpak flatpak-builder libfuse2 + flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo + flatpak install --user -y flathub org.freedesktop.Platform//24.08 + flatpak install --user -y flathub org.freedesktop.Sdk//24.08 + - name: Gradle caching uses: actions/cache@v5 with: @@ -117,48 +103,26 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Package Linux ".deb" distribution - run: ./gradlew :desktop:packageReleaseDeb + - name: Package Linux distributions + run: > + ./gradlew + :desktop:packageReleaseDeb + :desktop:packageReleaseRpm + :desktop:packageReleaseAppImage + :desktop:packageReleaseSnap + :desktop:packageReleaseFlatpak - - name: Rename DEB Artifact + - name: Stage Linux artifacts run: | - cd $GITHUB_WORKSPACE/desktop/build/installers/main-release/deb/ - # find the file matching the pattern and store its name in a variable - file=$(find . -type f -name 'hammer_*.deb' -print -quit) - - # if no file was found, exit with an error message - if [ -z "$file" ]; then - echo "Error: no file matching the pattern found." - exit 1 - fi - - # rename the file to "hammer.deb" - mv "$file" "${file/hammer_*/hammer}.deb" - - echo "File renamed successfully." - - - name: Package Linux ".rpm" distribution - run: ./gradlew :desktop:packageReleaseRpm - - - name: Rename RPM Artifact - run: | - cd $GITHUB_WORKSPACE/desktop/build/installers/main-release/rpm/ - # find the file matching the pattern and store its name in a variable - file=$(find . -type f -name 'hammer-*.rpm' -print -quit) - - # if no file was found, exit with an error message - if [ -z "$file" ]; then - echo "Error: no file matching the pattern found." - exit 1 - fi - - # rename the file to "hammer.rpm" - mv "$file" "hammer.rpm" - - echo "File renamed successfully." - - - name: Build Linux ".appimage" distribution - run: ./gradlew buildDistAppImage + STAGE="$GITHUB_WORKSPACE/release-artifacts" + mkdir -p "$STAGE" + ROOT="desktop/build/compose/binaries/main-release" + cp "$(find "$ROOT/deb" -maxdepth 2 -type f -name '*.deb' | head -1)" "$STAGE/hammer.deb" + cp "$(find "$ROOT/rpm" -maxdepth 2 -type f -name '*.rpm' | head -1)" "$STAGE/hammer.rpm" + cp "$(find "$ROOT/appimage" -maxdepth 2 -type f -name '*.AppImage' | head -1)" "$STAGE/hammer.AppImage" + cp "$(find "$ROOT/snap" -maxdepth 2 -type f -name '*.snap' | head -1)" "$STAGE/hammer.snap" + cp "$(find "$ROOT/flatpak" -maxdepth 2 -type f -name '*.flatpak' | head -1)" "$STAGE/hammer.flatpak" + ls -la "$STAGE" - name: Create Release uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0 @@ -169,7 +133,7 @@ jobs: prerelease: true artifactErrorsFailBuild: true allowUpdates: true - artifacts: "${{ github.workspace }}/desktop/build/installers/main-release/deb/hammer.deb,${{ github.workspace }}/desktop/build/installers/main-release/rpm/hammer.rpm,${{ github.workspace }}/desktop/build/installers/main-release/appimage/hammer.AppImage" + artifacts: "${{ github.workspace }}/release-artifacts/hammer.deb,${{ github.workspace }}/release-artifacts/hammer.rpm,${{ github.workspace }}/release-artifacts/hammer.AppImage,${{ github.workspace }}/release-artifacts/hammer.snap,${{ github.workspace }}/release-artifacts/hammer.flatpak" macos: runs-on: macos-latest @@ -183,6 +147,11 @@ jobs: distribution: 'adopt' java-version: 21 + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: 20 + - name: Gradle caching uses: actions/cache@v5 with: @@ -193,47 +162,20 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- - - name: Package MacOS ".dmg" distribution - run: ./gradlew :desktop:packageReleaseDmg + - name: Package macOS distributions + run: > + ./gradlew + :desktop:packageReleaseDmg + :desktop:packageReleasePkg - - name: Rename DMG Artifact + - name: Stage macOS artifacts run: | - cd $GITHUB_WORKSPACE/desktop/build/installers/main-release/dmg/ - # find the file matching the pattern and store its name in a variable - file=$(find . -type f -name 'hammer-*.dmg' -print -quit) - - # if no file was found, exit with an error message - if [ -z "$file" ]; then - echo "Error: no file matching the pattern found." - exit 1 - fi - - # rename the file to "hammer.dmg" - mv "$file" "${file/hammer-*/hammer}.dmg" - - echo "File renamed successfully." - - - name: Package MacOS ".pkg" distribution - run: ./gradlew :desktop:packageReleasePkg - - - name: Rename PKG Artifact - run: | - cd $GITHUB_WORKSPACE/desktop/build/installers/main-release/pkg/ - # find the file matching the pattern and store its name in a variable - file=$(find . -type f -name 'hammer-*.pkg' -print -quit) - - # if no file was found, exit with an error message - if [ -z "$file" ]; then - echo "Error: no file matching the pattern found." - exit 1 - fi - - # rename the file to "hammer.pkg" - mv "$file" "hammer.pkg" - - echo "File renamed successfully." - echo "Contents of pkg directory:" - ls -la + STAGE="$GITHUB_WORKSPACE/release-artifacts" + mkdir -p "$STAGE" + ROOT="desktop/build/compose/binaries/main-release" + cp "$(find "$ROOT/dmg" -maxdepth 2 -type f -name '*.dmg' | head -1)" "$STAGE/hammer.dmg" + cp "$(find "$ROOT/pkg" -maxdepth 2 -type f -name '*.pkg' | head -1)" "$STAGE/hammer.pkg" + ls -la "$STAGE" - name: Create Release uses: ncipollo/release-action@339a81892b84b4eeb0f6e744e4574d79d0d9b8dd # v1.21.0 @@ -244,7 +186,7 @@ jobs: prerelease: true artifactErrorsFailBuild: true allowUpdates: true - artifacts: "${{ github.workspace }}/desktop/build/installers/main-release/dmg/hammer.dmg,${{ github.workspace }}/desktop/build/installers/main-release/pkg/hammer.pkg" + artifacts: "${{ github.workspace }}/release-artifacts/hammer.dmg,${{ github.workspace }}/release-artifacts/hammer.pkg" server: runs-on: ubuntu-latest @@ -456,7 +398,7 @@ jobs: set-release-body: runs-on: ubuntu-latest - needs: [ windows, linux, macos, android, server, snap, flatpak ] + needs: [ windows, linux, macos, android, server ] if: success() steps: @@ -470,10 +412,10 @@ jobs: run: | TAG_NAME=${GITHUB_REF#refs/tags/} TAG_MESSAGE=$(git tag -n90 --format='%(contents)' "$TAG_NAME" ) - + echo "Tag: $TAG_NAME" echo -e "Tag message:\n$TAG_MESSAGE" - + echo "tag_message<> $GITHUB_ENV echo "$TAG_MESSAGE" >> $GITHUB_ENV echo "EOF" >> $GITHUB_ENV diff --git a/.github/workflows/publish-release.yml b/.github/workflows/publish-release.yml index 080975273..17ef725a6 100644 --- a/.github/workflows/publish-release.yml +++ b/.github/workflows/publish-release.yml @@ -90,18 +90,12 @@ jobs: needs: publish-google-play runs-on: windows-latest steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: set up JDK 21 - uses: actions/setup-java@v5 - with: - java-version: '21' - distribution: 'temurin' - cache: gradle - - - name: Build MSIX package - run: ./gradlew :desktop:packageMsix + - name: Download AppX from Release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + shell: bash + run: | + gh release download ${{ github.event.release.tag_name }} -p 'hammer.appx' -R ${{ github.repository }} - name: Submit to Microsoft Store shell: pwsh @@ -120,7 +114,7 @@ jobs: } $tokenResponse = Invoke-RestMethod -Uri "https://login.microsoftonline.com/$env:MS_TENANT_ID/oauth2/v2.0/token" -Method POST -Body $tokenBody $accessToken = $tokenResponse.access_token - + # Create new submission Write-Host "Creating new submission..." $headers = @{ @@ -130,31 +124,31 @@ jobs: $submissionResponse = Invoke-RestMethod -Uri "https://manage.devcenter.microsoft.com/v1.0/my/applications/$env:MS_APP_ID/submissions" -Method POST -Headers $headers $submissionId = $submissionResponse.id $fileUploadUrl = $submissionResponse.fileUploadUrl - + Write-Host "Submission ID: $submissionId" Write-Host "Upload URL: $fileUploadUrl" - - # Find MSIX file - $msixFile = Get-ChildItem -Path "desktop\build\installers\Hammer-*.msix" | Select-Object -First 1 - Write-Host "Uploading: $($msixFile.FullName)" - - # Upload MSIX to Azure Storage - $msixBytes = [System.IO.File]::ReadAllBytes($msixFile.FullName) + + # Find AppX file (downloaded from release) + $appxFile = Get-Item -Path "hammer.appx" + Write-Host "Uploading: $($appxFile.FullName)" + + # Upload AppX to Azure Storage + $appxBytes = [System.IO.File]::ReadAllBytes($appxFile.FullName) $headers = @{ "x-ms-blob-type" = "BlockBlob" } - Invoke-RestMethod -Uri $fileUploadUrl -Method PUT -Headers $headers -Body $msixBytes -ContentType "application/octet-stream" - + Invoke-RestMethod -Uri $fileUploadUrl -Method PUT -Headers $headers -Body $appxBytes -ContentType "application/octet-stream" + Write-Host "Upload complete!" - + # Commit submission Write-Host "Committing submission..." $headers = @{ Authorization = "Bearer $accessToken" } Invoke-RestMethod -Uri "https://manage.devcenter.microsoft.com/v1.0/my/applications/$env:MS_APP_ID/submissions/$submissionId/commit" -Method POST -Headers $headers - - Write-Host "✓ Submission committed successfully!" + + Write-Host "Submission committed successfully!" notify: needs: [ publish-google-play, publish-snap ] @@ -165,4 +159,4 @@ jobs: DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }} uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554 # 0.4.0 with: - args: "**New release:** {{ EVENT_PAYLOAD.release.name }}\n**Download Here:** {{ EVENT_PAYLOAD.release.html_url }}\n\n**Changelog:**\n{{ EVENT_PAYLOAD.release.body }}" \ No newline at end of file + args: "**New release:** {{ EVENT_PAYLOAD.release.name }}\n**Download Here:** {{ EVENT_PAYLOAD.release.html_url }}\n\n**Changelog:**\n{{ EVENT_PAYLOAD.release.body }}"