repush #36
Workflow file for this run
This file contains 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 and Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
env: | |
FILE_NAME: connect4 | |
OUT_DIR: out | |
VERSION: ${{ github.ref_name }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
release_upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Compile and Build JAR | |
run: | | |
mkdir ${{ env.OUT_DIR }} | |
javac -d ${{ env.OUT_DIR }} src/*.java | |
jar cvfm ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-${{ env.VERSION }}.jar customManifest.txt -C ${{ env.OUT_DIR }} ./ | |
- name: Upload JAR as Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }} | |
path: ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-${{ env.VERSION }}.jar | |
- name: Create GitHub Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: Release ${{ github.ref }} | |
- name: Attach JAR to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-${{ env.VERSION }}.jar | |
asset_name: ${{ env.FILE_NAME }}-${{ env.VERSION }}.jar | |
asset_content_type: application/java-archive | |
macos_build: | |
needs: build | |
runs-on: macOS-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download JAR from artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }} | |
path: ${{ env.OUT_DIR }} | |
- name: Create Standalone for MacOS | |
run: jpackage --input ${{ env.OUT_DIR }} --name ${{ env.FILE_NAME }} --main-jar ${{ env.FILE_NAME }}-${{ env.VERSION }}.jar --main-class App --type dmg --dest . | |
- name: List contents of out directory | |
run: ls ${{ env.OUT_DIR }} | |
- name: Rename MacOS standalone | |
run: mv ${{ env.FILE_NAME }}-1.0.dmg ${{ env.FILE_NAME }}-MacOS-${{ env.VERSION }}.dmg | |
- name: Attach MacOS Standalone to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.build.outputs.release_upload_url }} | |
asset_path: ./${{ env.FILE_NAME }}-MacOS-${{ env.VERSION }}.dmg | |
asset_name: ${{ env.FILE_NAME }}-MacOS-${{ env.VERSION }}.dmg | |
asset_content_type: application/octet-stream | |
ubuntu_build: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download JAR from artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }} | |
path: ${{ env.OUT_DIR }} | |
- name: Create Standalone for Ubuntu | |
run: jpackage --input ${{ env.OUT_DIR }} --name ${{ env.FILE_NAME }} --main-jar ${{ env.FILE_NAME }}-${{ env.VERSION }}.jar --main-class App --type deb --dest . | |
- name: List contents of out directory | |
run: ls -lh . | |
- name: Rename Ubuntu standalone | |
run: mv ${{ env.FILE_NAME }}_1.0-1_amd64.deb ${{ env.FILE_NAME }}-Ubuntu-${{ env.VERSION }}_amd64.deb | |
- name: Attach Ubuntu Standalone to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.build.outputs.release_upload_url }} | |
asset_path: ./${{ env.FILE_NAME }}-Ubuntu-${{ env.VERSION }}_amd64.deb | |
asset_name: ${{ env.FILE_NAME }}-Ubuntu-${{ env.VERSION }}_amd64.deb | |
asset_content_type: application/octet-stream | |
windows_build: | |
needs: build | |
runs-on: windows-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download JAR from artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.FILE_NAME }}-jar-${{ env.VERSION }} | |
path: ${{ env.OUT_DIR }} | |
- name: Setup Java 16 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '16' | |
distribution: 'temurin' | |
- name: Create Standalone for Windows | |
run: jpackage --input ${{ env.OUT_DIR }} --name ${{ env.FILE_NAME }} --main-jar ${{ env.FILE_NAME }}-${{ env.VERSION }}.jar --main-class App --type exe --dest . | |
- name: List contents of out directory (Windows) | |
run: Get-ChildItem -Path . | |
- name: Rename Windows standalone | |
run: move ${{ env.FILE_NAME }}-1.0.exe ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-Windows-${{ env.VERSION }}.exe | |
- name: Attach Windows Standalone to Release | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.build.outputs.release_upload_url }} | |
asset_path: ${{ env.OUT_DIR }}/${{ env.FILE_NAME }}-Windows-${{ env.VERSION }}.exe | |
asset_name: ${{ env.FILE_NAME }}-Windows-${{ env.VERSION }}.exe | |
asset_content_type: application/octet-stream | |