Skip to content

repush

repush #61

Workflow file for this run

name: Build and Release
on:
push:
tags:
- 'v*'
env:
FILE_NAME: connect4
ICON_NAME: connect4-512
MAIN_CLASS: App
OUT_DIR: out
VERSION: ${{ github.ref_name }}
jobs:
build:
runs-on: ubuntu-latest
outputs:
release_upload_url: ${{ steps.create_release.outputs.upload_url }}
stripped_version: ${{ steps.get_stripped_version.outputs.version }}
steps:
- name: Get stripped version
id: get_stripped_version
run: |
STRIPPED_VERSION=${VERSION#v}
echo "Stripped version: $STRIPPED_VERSION"
echo "::set-output name=version::$STRIPPED_VERSION"
- name: Checkout code
uses: actions/checkout@v3
- name: Extract release notes from changelog
id: changelog_reader
uses: mindsers/[email protected]
with:
validation_level: warn
version: ${{ env.VERSION }}
path: ./CHANGELOG.md
- name: Compile and Build JAR
run: |
mkdir ${{ env.OUT_DIR }}
javac -d ${{ env.OUT_DIR }} src/*.java
# Generate a temporary manifest file using echo
echo "Main-Class: ${{ env.MAIN_CLASS }}" > customManifest.txt
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: ${{ github.ref_name }}
body: ${{ steps.changelog_reader.outputs.changes }}
- 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 ${{ env.MAIN_CLASS }} \
--icon assets/icon/${{ env.ICON_NAME }}.icns \
--app-version ${{ needs.build.outputs.stripped_version }} \
--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 }}-${{ needs.build.outputs.stripped_version }}.dmg
asset_name: ${{ env.FILE_NAME }}-${{ needs.build.outputs.stripped_version }}-MacOS.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 ${{ env.MAIN_CLASS }} \
--icon assets/icon/${{ env.ICON_NAME }}.png \
--resource-dir resources \
--app-version ${{ needs.build.outputs.stripped_version }} \
--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 }}_${{ needs.build.outputs.stripped_version }}-1_amd64.deb
asset_name: ${{ env.FILE_NAME }}-${{ env.VERSION }}-linux_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 out `
--name ${{ env.FILE_NAME }} `
--main-jar ${{ env.FILE_NAME }}-${{ env.VERSION }}.jar `
--main-class ${{ env.MAIN_CLASS }} `
--icon assets/icon/${{ env.ICON_NAME }}.ico `
--win-shortcut `
--app-version ${{ needs.build.outputs.stripped_version }} `
--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.FILE_NAME }}-${{ needs.build.outputs.stripped_version }}.exe
asset_name: ${{ env.FILE_NAME }}-${{ needs.build.outputs.stripped_version }}-windows.exe
asset_content_type: application/octet-stream