Adding homebrew build #63
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: Package and deploy versions | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
project-info: | |
runs-on: ubuntu-latest | |
container: | |
image: ubuntu:latest | |
outputs: | |
PROJECT_ARTIFACT: ${{ steps.project-info.outputs.PROJECT_ARTIFACT }} | |
PROJECT_VERSION: ${{ steps.project-info.outputs.PROJECT_VERSION }} | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Install tools | |
run: | | |
apt-get update | |
apt-get install -y jq libxml2-utils | |
- name: Store Project Information | |
id: project-info | |
run: | | |
PROJECT_VERSION=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="version"]/text()' pom.xml | sed 's/-SNAPSHOT/.${{github.run_number}}'/) | |
echo "PROJECT_VERSION=${PROJECT_VERSION}" | |
echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_OUTPUT | |
PROJECT_ARTIFACT=$(xmllint --xpath '/*[local-name()="project"]/*[local-name()="artifactId"]/text()' pom.xml) | |
echo "PROJECT_ARTIFACT=${PROJECT_ARTIFACT}" | |
echo "PROJECT_ARTIFACT=${PROJECT_ARTIFACT}" >> $GITHUB_OUTPUT | |
linux-deb: | |
needs: project-info | |
runs-on: ubuntu-latest | |
container: | |
image: ubuntu:latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Install tools | |
run: | | |
apt-get update | |
apt-get install -y jq git libxml2-utils curl zip unzip tar gzip gcc zlib1g-dev fakeroot | |
- uses: sdkman/sdkman-action@main | |
id: sdkman | |
with: | |
candidate: java | |
version: 21.0.2-open | |
- run: java -version | |
- run: which java && java -version && echo $JAVA_HOME | |
- name: Set Version | |
run: | | |
./mvnw -U --batch-mode versions:set dependency:tree -DnewVersion=${{ needs.project-info.outputs.PROJECT_VERSION }} | |
- name: Build DEB | |
run: | | |
JAVA_HOME=/github/home/.sdkman/candidates/java/current ./mvnw -Plinux-deb --batch-mode install | |
ls target/jpackage | |
- name: 'Upload Jar' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}.jar | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}.jar | |
retention-days: 1 | |
if-no-files-found: error | |
- name: 'Upload Shaded' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-shaded.jar | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-shaded.jar | |
retention-days: 1 | |
if-no-files-found: error | |
- name: 'Upload DEB' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}_${{ needs.project-info.outputs.PROJECT_VERSION }}_amd64.deb | |
path: ./target/jpackage/github-actions-notifier_${{ needs.project-info.outputs.PROJECT_VERSION }}_amd64.deb | |
retention-days: 1 | |
if-no-files-found: error | |
linux-rpm: | |
needs: project-info | |
runs-on: ubuntu-latest | |
container: | |
image: fedora:latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Install tools | |
run: | | |
yum -y install jq git libxml2 curl zip unzip tar gzip gcc zlib-devel fakeroot rpm-build | |
- uses: sdkman/sdkman-action@main | |
id: sdkman | |
with: | |
candidate: java | |
version: 21.0.2-open | |
- run: java -version | |
- run: java -version && echo $JAVA_HOME | |
- name: Set Version | |
run: | | |
./mvnw -U --batch-mode versions:set dependency:tree -DnewVersion=${{ needs.project-info.outputs.PROJECT_VERSION }} | |
- name: Build RPM | |
run: | | |
JAVA_HOME=/github/home/.sdkman/candidates/java/current ./mvnw --batch-mode -Plinux-rpm install | |
ls target/jpackage | |
- name: 'Upload RPM' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}_${{ needs.project-info.outputs.PROJECT_VERSION }}_x86_64.rpm | |
path: ./target/jpackage/github-actions-notifier-${{ needs.project-info.outputs.PROJECT_VERSION }}-1.x86_64.rpm | |
retention-days: 1 | |
if-no-files-found: error | |
mac-arm: | |
needs: project-info | |
runs-on: macos-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '22' | |
distribution: 'graalvm' | |
github-token: ${{ github.token }} | |
- run: java -version | |
name: Java Info | |
- run: java -version && echo $JAVA_HOME && uname -a | |
- name: Set Version | |
run: | | |
./mvnw -U --batch-mode versions:set dependency:tree -DnewVersion=${{ needs.project-info.outputs.PROJECT_VERSION }} | |
- name: Build | |
run: ./mvnw --batch-mode -Pmac-arm clean package && ls target | |
- name: 'Upload Mac Binary' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-ARM_64.dmg | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-ARM_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | |
retention-days: 1 | |
if-no-files-found: error | |
mac-intel: | |
needs: project-info | |
runs-on: macos-12 | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '22' | |
distribution: 'graalvm' | |
github-token: ${{ github.token }} | |
- run: java -version && uname -a | |
- name: Set Version | |
run: | | |
./mvnw -U --batch-mode versions:set dependency:tree -DnewVersion=${{ needs.project-info.outputs.PROJECT_VERSION }} | |
- name: Build | |
run: ./mvnw --batch-mode -Pmac-intel clean package | |
- name: 'Upload Mac Binary' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-x86_64.dmg | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-x86_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | |
retention-days: 1 | |
if-no-files-found: error | |
windows-intel: | |
needs: project-info | |
runs-on: windows-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- uses: ilammy/msvc-dev-cmd@v1 | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '22' | |
distribution: 'graalvm' | |
github-token: ${{ github.token }} | |
- run: java -version | |
- name: Set Version | |
run: | | |
./mvnw -U --batch-mode versions:set dependency:tree "-DnewVersion=${{ needs.project-info.outputs.PROJECT_VERSION }}" | |
- name: Build | |
run: | | |
./mvnw --batch-mode install | |
dir target | |
jpackage --dest D:\a\gha-notifier\gha-notifier\target\jpackage --type msi --app-version '1.0.${{github.run_number}}' --name 'GitHub Actions Notifier' --icon D:\a\gha-notifier\gha-notifier\src\bundle\icon.ico --input D:\a\gha-notifier\gha-notifier\src\bundle --main-jar 'D:\a\gha-notifier\gha-notifier\target\gha-notifier-1.0.${{github.run_number}}-shaded.jar' --win-menu --win-shortcut | |
dir target\jpackage | |
- name: 'Upload Windows Binary' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}.msi | |
path: ./target/jpackage/GitHub Actions Notifier-${{ needs.project-info.outputs.PROJECT_VERSION }}.msi | |
retention-days: 1 | |
if-no-files-found: error | |
release: | |
runs-on: ubuntu-latest | |
container: | |
image: ubuntu:latest | |
needs: [ project-info, linux-deb, linux-rpm, windows-intel, mac-arm, mac-intel ] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '22' | |
distribution: 'graalvm' | |
github-token: ${{ github.token }} | |
- run: java -version && uname -a | |
- name: Set Version | |
run: | | |
./mvnw -U --batch-mode versions:set dependency:tree -DnewVersion=${{ needs.project-info.outputs.PROJECT_VERSION }} | |
- name: Download Artifacts | |
uses: actions/checkout@v3 | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: target | |
merge-multiple: true | |
- name: List | |
run: ls -al target | |
- name: release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
draft: false | |
prerelease: false | |
release_name: ${{ needs.project-info.outputs.PROJECT_VERSION }} | |
tag_name: ${{ needs.project-info.outputs.PROJECT_VERSION }} | |
body_path: README.md | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Upload JAR | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}.jar | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}.jar | |
asset_content_type: application/java-archive | |
- name: Upload Shaded JAR | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-shaded.jar | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-shaded.jar | |
asset_content_type: application/java-archive | |
- name: Upload DEB | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/github-actions-notifier_${{ needs.project-info.outputs.PROJECT_VERSION }}_amd64.deb | |
asset_name: github-actions-notifier_${{ needs.project-info.outputs.PROJECT_VERSION }}_amd64.deb | |
asset_content_type: application/vnd.debian.binary-package | |
- name: Upload RPM | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/github-actions-notifier-${{ needs.project-info.outputs.PROJECT_VERSION }}-1.x86_64.rpm | |
asset_name: github-actions-notifier-${{ needs.project-info.outputs.PROJECT_VERSION }}-1.x86_64.rpm | |
asset_content_type: application/x-rpm | |
- name: Upload Mac ARM | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-ARM_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-ARM_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | |
asset_content_type: application/octet-stream | |
- name: Upload Mac Intel | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-x86_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-x86_64_${{ needs.project-info.outputs.PROJECT_VERSION }}.dmg | |
asset_content_type: application/octet-stream | |
- name: Windows | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: ./target/GitHub Actions Notifier-${{ needs.project-info.outputs.PROJECT_VERSION }}.msi | |
asset_name: GitHub Actions Notifier-${{ needs.project-info.outputs.PROJECT_VERSION }}.msi | |
asset_content_type: application/octet-stream | |
- name: Install tools | |
run: | | |
apt-get update | |
apt-get install -y wget git | |
- name: Build Homebrew Formula | |
run: | | |
wget https://github.com/atl-tw/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}/archive/refs/tags/${{ needs.project-info.outputs.PROJECT_VERSION }}.zip | |
ZIP_SHA=$(shasum -a 256 ${{ needs.project-info.outputs.PROJECT_VERSION }}.zip | awk '{print $1}') | |
./mvnw "-Dbrew.asset.url=https://github.com/atl-tw/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}/archive/refs/tags/${{ needs.project-info.outputs.PROJECT_VERSION }}.zip" -Dbrew.asset.hash=$ZIP_SHA --batch-mode package | |
- name: Publish Homebrew | |
env: | |
DESTINATION_BRANCH: main | |
DESTINATION_REPOSITORY: 'atl-tw/homebrew-tap' | |
API_TOKEN_GITHUB: ${{ secrets.MAVEN_TOKEN }} | |
COMMIT_EMAIL: rcooper@thoughtworks.com | |
COMMIT_USERNAME: ${{secrets.MAVEN_USER}} | |
COMMIT_MESSAGE: "Updating ${{ needs.project-info.outputs.PROJECT_ARTIFACT }} to -${{ needs.project-info.outputs.PROJECT_VERSION }}" | |
SOURCE_FILES: 'target/brew/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}/*' | |
DESTINATION_DIRECTORY: '' | |
run: | | |
.github/workflows/deploy-homebrew.sh |