Working on homebrew #62
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-build: | |
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 nsis curl zip unzip tar gzip gcc zlib1g-dev | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '22' | |
distribution: 'graalvm' | |
github-token: ${{ github.token }} | |
- run: which java && 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 -Pnative -Dagent=true -Dosname.short=Linux clean install | |
- 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 Zip' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-anyos.zip | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-anyos.zip | |
retention-days: 1 | |
if-no-files-found: error | |
- name: 'Upload TGZ' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-anyos.tar.gz | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-anyos.tar.gz | |
retention-days: 1 | |
if-no-files-found: error | |
- name: 'Upload Windows Installer' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-installer.exe | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-installer.exe | |
retention-days: 1 | |
if-no-files-found: error | |
- name: 'Upload Linux Binary' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Linux-amd64.bin | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Linux-amd64 | |
retention-days: 1 | |
if-no-files-found: error | |
windows-build: | |
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 -Pnative -Dagent=true clean package && ls target | |
- name: 'Upload Windows Binary' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Windows-amd64.exe | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Windows-amd64.exe | |
retention-days: 1 | |
if-no-files-found: error | |
mac-build: | |
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 | |
- run: brew install makensis | |
- 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 -Pnative -Dagent=true 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 }}-Mac-x86_64.bin | |
path: ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Mac-x86_64 | |
retention-days: 1 | |
if-no-files-found: error | |
release: | |
runs-on: ubuntu-latest | |
container: | |
image: ubuntu:latest | |
needs: [project-info, linux-build, windows-build, mac-build] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Download All Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
path: target | |
merge-multiple: true | |
- 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 Zip | |
id: upload-zip | |
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 }}-anyos.zip | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-anyos.zip | |
asset_content_type: application/zip | |
- name: Upload TGZ | |
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 }}-anyos.tar.gz | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-anyos.tar.gz | |
asset_content_type: application/tar+gzip | |
- name: Upload EXE | |
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 }}-installer.exe | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-installer.exe | |
asset_content_type: application/tar+gzip | |
- name: Upload Linux Bin | |
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 }}-Linux-amd64 | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Linux-amd64.bin | |
asset_content_type: application/octet-stream | |
- name: Upload Mac Bin | |
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 }}-Mac-x86_64 | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Mac-x86_64.bin | |
asset_content_type: application/octet-stream | |
- name: Upload Windows Bin | |
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 }}-Windows-amd64.exe | |
asset_name: ${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-Windows-amd64.exe | |
asset_content_type: application/octet-stream | |
- uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: '22' | |
distribution: 'graalvm' | |
github-token: ${{ github.token }} | |
- run: which java && java -version | |
- name: Install tools | |
run: | | |
apt-get update | |
apt-get install -y jq git libxml2-utils nsis curl zip unzip tar gzip gcc zlib1g-dev | |
- name: Set Version | |
run: | | |
./mvnw -U --batch-mode versions:set dependency:tree -DnewVersion=${{ needs.project-info.outputs.PROJECT_VERSION }} | |
- name: Deploy to Github Package Registry | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
run: | | |
mkdir -p ~/.m2 | |
echo "<settings><servers><server><id>gh</id><username>${{secrets.MAVEN_USER}}</username><password>${{secrets.MAVEN_TOKEN}}</password></server></servers></settings>" > settings.xml | |
ZIP_SHA=$(shasum -a 256 ./target/${{ needs.project-info.outputs.PROJECT_ARTIFACT }}-${{ needs.project-info.outputs.PROJECT_VERSION }}-anyos.zip | awk '{print $1}') | |
./mvnw -s ./settings.xml -Dbrew.asset.url=${{ steps.upload-zip.outputs.browser_download_url}} -Dbrew.asset.hash=${{ steps.upload-zip.outputs.browser_download_url}} --batch-mode deploy | |
- name: Publish Homebrew | |
env: | |
DESTINATION_BRANCH: main | |
DESTINATION_REPOSITORY: 'atl-tw/homebrew-tap' | |
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }} | |
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: 'brew' | |
run: | | |
bin/deploy-homebrew.sh | |