ci: add contents:write permission to build job for release creation #17
Workflow file for this run
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: Build Standalone Binaries | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| tags: | |
| - 'v*' | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ${{ matrix.os }} | |
| permissions: | |
| contents: write | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '17' | |
| distribution: 'temurin' | |
| cache: maven | |
| - name: Build with Maven | |
| run: mvn -B clean package -DskipTests | |
| - name: Get JDK Modules (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| MODULES=$(jdeps --ignore-missing-deps -q --multi-release 17 --print-module-deps target/java2graph-1.0-SNAPSHOT-jar-with-dependencies.jar || echo "java.base,java.compiler,java.desktop,java.instrument,java.management,java.sql,jdk.attach,jdk.jdi,jdk.unsupported") | |
| echo "MODULES=${MODULES},java.logging,jdk.compiler,jdk.zipfs" >> $GITHUB_ENV | |
| shell: bash | |
| - name: Get JDK Modules (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| $MODULES = $(jdeps --ignore-missing-deps -q --multi-release 17 --print-module-deps target/java2graph-1.0-SNAPSHOT-jar-with-dependencies.jar) | |
| if (-not $MODULES) { $MODULES = "java.base,java.compiler,java.desktop,java.instrument,java.management,java.sql,jdk.attach,jdk.jdi,jdk.unsupported" } | |
| echo "MODULES=${MODULES},java.logging,jdk.compiler,jdk.zipfs" >> $env:GITHUB_ENV | |
| - name: Create minimal JRE with jlink | |
| run: | | |
| jlink --add-modules ${{ env.MODULES }} --bind-services --strip-debug --no-man-pages --no-header-files --compress=2 --output custom-jre | |
| - name: Package with jpackage (Linux/macOS) | |
| if: runner.os != 'Windows' | |
| run: | | |
| jpackage --type app-image --name java2graph --input target --main-jar java2graph-1.0-SNAPSHOT-jar-with-dependencies.jar --main-class com.neuvem.java2graph.Main --runtime-image custom-jre --dest dist | |
| cd dist | |
| tar -czvf java2graph-${{ runner.os }}.tar.gz java2graph* | |
| - name: Package with jpackage (Windows) | |
| if: runner.os == 'Windows' | |
| run: | | |
| jpackage --type app-image --name java2graph --input target --main-jar java2graph-1.0-SNAPSHOT-jar-with-dependencies.jar --main-class com.neuvem.java2graph.Main --runtime-image custom-jre --dest dist | |
| Compress-Archive -Path dist\java2graph -DestinationPath dist\java2graph-Windows.zip | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: java2graph-${{ runner.os }} | |
| path: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| - name: Publish GitHub Release | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/') | |
| with: | |
| files: | | |
| dist/*.tar.gz | |
| dist/*.zip | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |