fix: make sure the latest nightly no tags but sha short #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Nightly Build | |
| on: | |
| push: | |
| branches: [ main ] | |
| permissions: | |
| contents: write | |
| jobs: | |
| cleanup: | |
| name: Delete Old Nightly Release | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Delete current nightly release | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| gh release delete nightly --cleanup-tag -y || true | |
| nightly-release: | |
| needs: cleanup | |
| name: Nightly Release on ${{ matrix.os }} | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| platform: linux | |
| - os: windows-latest | |
| platform: windows | |
| - os: macos-latest | |
| platform: macos | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 21 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| cache: 'maven' | |
| - name: Set Version | |
| id: version | |
| shell: bash | |
| run: | | |
| # Use run_number to ensure strictly increasing version numbers for installers | |
| # Windows MSI limit: Major (0-255), Minor (0-255), Build (0-65535) | |
| # We use 1.0.RUN_NUMBER | |
| VERSION="1.0.${{ github.run_number }}" | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| # Get Short SHA | |
| SHA_SHORT=$(git rev-parse --short HEAD) | |
| echo "SHA_SHORT=$SHA_SHORT" >> $GITHUB_ENV | |
| echo "Nightly Version: $VERSION ($SHA_SHORT)" | |
| # 1. Build the shaded JAR | |
| - name: Build with Maven | |
| run: mvn clean package -DskipTests | |
| # 2. Prepare Staging | |
| - name: Prepare Staging | |
| shell: bash | |
| run: | | |
| mkdir -p target/staging | |
| cp target/query-worker-1.0.0.jar target/staging/ | |
| # 3. Create Installers | |
| # LINUX | |
| - name: Create Linux Installers | |
| if: runner.os == 'Linux' | |
| run: | | |
| jpackage \ | |
| --name "query-worker-nightly" \ | |
| --input target/staging \ | |
| --main-jar query-worker-1.0.0.jar \ | |
| --app-version "${{ env.VERSION }}" \ | |
| --dest target/installer \ | |
| --java-options "-Xmx2048m" \ | |
| --linux-shortcut \ | |
| --linux-menu-group "Development" \ | |
| --verbose \ | |
| --type deb | |
| # WINDOWS | |
| - name: Create Windows Installer | |
| if: runner.os == 'Windows' | |
| shell: cmd | |
| run: | | |
| jpackage ^ | |
| --name "QueryWorkerNightly" ^ | |
| --input target\staging ^ | |
| --main-jar query-worker-1.0.0.jar ^ | |
| --type msi ^ | |
| --app-version "${{ env.VERSION }}" ^ | |
| --dest target\installer ^ | |
| --java-options "-Xmx2048m" ^ | |
| --win-dir-chooser ^ | |
| --win-menu ^ | |
| --win-shortcut ^ | |
| --verbose | |
| # MACOS | |
| - name: Create macOS Installer | |
| if: runner.os == 'macOS' | |
| run: | | |
| jpackage \ | |
| --name "QueryWorkerNightly" \ | |
| --input target/staging \ | |
| --main-jar query-worker-1.0.0.jar \ | |
| --type dmg \ | |
| --app-version "${{ env.VERSION }}" \ | |
| --dest target/installer \ | |
| --java-options "-Xmx2048m" \ | |
| --mac-package-name "QueryWorkerNightly" \ | |
| --verbose | |
| # NEW: Rename installers to generic names to prevent clutter in Nightly release | |
| - name: Rename Installers (add short commit) | |
| shell: bash | |
| run: | | |
| # Use simple glob expansion since there's exactly one installer file per type in this dir | |
| mv target/installer/*.dmg target/installer/query-worker-nightly-${{ env.SHA_SHORT }}.dmg || true | |
| mv target/installer/*.msi target/installer/query-worker-nightly-${{ env.SHA_SHORT }}.msi || true | |
| mv target/installer/*.deb target/installer/query-worker-nightly-${{ env.SHA_SHORT }}.deb || true | |
| # 4. Upload Assets to Nightly Release | |
| # Note: 'action-gh-release' handles updating the tag if we point to a fixed tag name | |
| - name: Upload Nightly Assets | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| tag_name: nightly | |
| name: Nightly Build (${{ env.SHA_SHORT }}) | |
| body: | | |
| Latest nightly build from commit ${{ github.sha }} | |
| prerelease: true | |
| files: | | |
| target/installer/query-worker-nightly-${{ env.SHA_SHORT }}.deb | |
| target/installer/query-worker-nightly-${{ env.SHA_SHORT }}.msi | |
| target/installer/query-worker-nightly-${{ env.SHA_SHORT }}.dmg | |