Skip to content

Commit

Permalink
Generate an ARM OSX binary and publish it to SDKMan and Homebrew (#2474)
Browse files Browse the repository at this point in the history
* Generate an ARM OSX binary and publish it to SDKMan and Homebrew

Homebrew cask change is here micronaut-projects/homebrew-tap#7

Closes #2473

* Combine arm and intel snapshots in the same file
  • Loading branch information
timyates authored Apr 29, 2024
1 parent 98de56e commit aec9474
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/mn-linux-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- name: "☕️ Setup GraalVM CE"
uses: graalvm/[email protected]
with:
version: '22.3.2'
java-version: '17'
distribution: 'graalvm-community'
native-image-musl: 'true'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
43 changes: 41 additions & 2 deletions .github/workflows/mn-macos-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ on:
branches:
- '[1-9]+.[0-9]+.x'
jobs:
build:
name: Builds OS X Native CLI
intel:
name: Builds OS X Intel Native CLI
runs-on: macos-13
steps:
- name: "⬇ Checkout the repository"
Expand Down Expand Up @@ -46,3 +46,42 @@ jobs:
with:
name: mn-darwin-amd64-snapshot
path: mn-darwin-amd64-snapshot.zip
arm:
name: Builds OS X Arm Native CLI
runs-on: macos-latest
steps:
- name: "⬇ Checkout the repository"
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: "☕️ Setup GraalVM CE"
uses: graalvm/[email protected]
with:
java-version: '17'
distribution: 'graalvm-community'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image"
run: ./gradlew micronaut-cli:nativeCompile --no-daemon
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
- name: "✅ Verify Build"
run: ./starter-cli/build/native/nativeCompile/mn --version
- name: "✅ Verify Create App"
run: ./starter-cli/build/native/nativeCompile/mn create-app test
- name: "👷‍♀️Package Build"
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
mkdir -p mn-darwin-aarch64-snapshot/bin
mv ./starter-cli/build/native/nativeCompile/mn mn-darwin-aarch64-snapshot/bin
cp ./LICENSE mn-darwin-aarch64-snapshot/
zip -r mn-darwin-aarch64-snapshot.zip ./mn-darwin-aarch64-snapshot -x '*.DS_Store*' -x '__MAC_OSX'
- name: "🆙 Upload Snapshot"
if: success() && github.event_name == 'push' && github.ref == 'refs/heads/4.4.x'
uses: actions/upload-artifact@v4
with:
name: mn-darwin-aarch64-snapshot
path: mn-darwin-aarch64-snapshot.zip
2 changes: 1 addition & 1 deletion .github/workflows/mn-windows-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
- name: "☕️ Setup GraalVM CE"
uses: graalvm/[email protected]
with:
version: '22.3.2'
java-version: '17'
distribution: 'graalvm-community'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image"
Expand Down
85 changes: 71 additions & 14 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ jobs:
- name: "☕️ Setup GraalVM CE"
uses: graalvm/[email protected]
with:
version: '22.3.2'
java-version: '17'
distribution: 'graalvm-community'
native-image-musl: 'true'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -143,8 +143,8 @@ jobs:
asset_name: mn-linux-amd64-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip
macos:
name: Release OS X Native CLI
runs-on: macos-latest
name: Release OS X Intel Native CLI
runs-on: macos-13
needs: [build]
steps:
- name: Checkout repository
Expand All @@ -160,8 +160,8 @@ jobs:
- name: "☕️ Setup GraalVM CE"
uses: graalvm/[email protected]
with:
version: '22.3.2'
java-version: '17'
distribution: 'graalvm-community'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image"
Expand Down Expand Up @@ -192,6 +192,56 @@ jobs:
asset_path: ./mn-darwin-amd64-${{ github.event.release.tag_name }}.zip
asset_name: mn-darwin-amd64-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip
macos-arm:
name: Release OS X Arm Native CLI
runs-on: macos-latest
needs: [build]
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
- name: Set the current release version
id: release_version
run: |
release_version=${GITHUB_REF:11}
sed -i -e "s/^projectVersion.*$/projectVersion\=${release_version}/" gradle.properties
echo "release_version=${release_version}" >> $GITHUB_OUTPUT
- name: "☕️ Setup GraalVM CE"
uses: graalvm/[email protected]
with:
java-version: '17'
distribution: 'graalvm-community'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image"
run: ./gradlew micronaut-cli:nativeCompile --no-daemon
env:
GRADLE_ENTERPRISE_ACCESS_KEY: ${{ secrets.GRADLE_ENTERPRISE_ACCESS_KEY }}
GRADLE_ENTERPRISE_CACHE_USERNAME: ${{ secrets.GRADLE_ENTERPRISE_CACHE_USERNAME }}
GRADLE_ENTERPRISE_CACHE_PASSWORD: ${{ secrets.GRADLE_ENTERPRISE_CACHE_PASSWORD }}
- name: "✅ Verify Build"
run: ./starter-cli/build/native/nativeCompile/mn --version
- name: "✅ Verify Create App"
run: ./starter-cli/build/native/nativeCompile/mn create-app test
- name: Package Build
env:
VERSION: ${{ github.event.release.tag_name }}
run: |
mkdir -p "mn-darwin-aarch64-${VERSION}/bin"
mv ./starter-cli/build/native/nativeCompile/mn "mn-darwin-aarch64-${VERSION}/bin"
cp ./LICENSE "mn-darwin-aarch64-${VERSION}/"
zip -r "mn-darwin-aarch64-${VERSION}.zip" "mn-darwin-aarch64-${VERSION}/" -x '*.DS_Store*' -x '__MAC_OSX'
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./mn-darwin-aarch64-${{ github.event.release.tag_name }}.zip
asset_name: mn-darwin-aarch64-${{ github.event.release.tag_name }}.zip
asset_content_type: application/zip
windows:
name: Release Windows Native CLI
runs-on: windows-latest
Expand All @@ -204,8 +254,8 @@ jobs:
- name: "☕️ Setup GraalVM CE"
uses: graalvm/[email protected]
with:
version: '22.3.2'
java-version: '17'
distribution: 'graalvm-community'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: "📸 Build the Native Image"
Expand Down Expand Up @@ -244,7 +294,7 @@ jobs:
sdkman:
name: Release to SDKMAN!
runs-on: ubuntu-latest
needs: [linux, macos, windows]
needs: [linux, macos, macos-arm, windows]
steps:
- name: Checkout repository
uses: actions/checkout@v4
Expand Down Expand Up @@ -318,28 +368,35 @@ jobs:
gcloud beta run deploy "micronaut-starter-$version" --quiet --image gcr.io/${{ secrets.GCLOUD_PROJECT }}/micronaut-starter:${{ steps.release_version.outputs.release_version }} --project ${{ secrets.GCLOUD_PROJECT }} --region us-central1 --update-env-vars=HOSTNAME="launch.micronaut.io",GITHUB_OAUTH_APP_CLIENT_ID=${{ secrets.GH_OAUTH_CLIENT_ID }},GITHUB_OAUTH_APP_CLIENT_SECRET=${{ secrets.GH_OAUTH_CLIENT_SECRET }} --platform managed --allow-unauthenticated --service-account=${{ secrets.GCLOUD_EMAIL }}
homebrew:
name: Update Homebrew cask
needs: [macos]
needs: [macos, macos-arm]
runs-on: ubuntu-latest
steps:
- name: Checkout https://github.com/micronaut-projects/homebrew-tap
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
repository: micronaut-projects/homebrew-tap
- name: Download ZIP
run: wget -q https://github.com/micronaut-projects/micronaut-starter/releases/download/${{ github.event.release.tag_name }}/mn-darwin-amd64-${{ github.event.release.tag_name }}.zip -O mn.zip
- name: Download Intel ZIP
run: wget -q https://github.com/micronaut-projects/micronaut-starter/releases/download/${{ github.event.release.tag_name }}/mn-darwin-amd64-${{ github.event.release.tag_name }}.zip -O intel.zip
- name: Download Arm ZIP
run: wget -q https://github.com/micronaut-projects/micronaut-starter/releases/download/${{ github.event.release.tag_name }}/mn-darwin-aarch64-${{ github.event.release.tag_name }}.zip -O arm.zip
- name: Calculate SHA256
id: sha
run: |
s=$(sha256sum mn.zip | awk '{ print $1 }')
echo "SHA256 is: $s"
echo "sha=${s}" >> $GITHUB_OUTPUT
s=$(sha256sum intel.zip | awk '{ print $1 }')
echo "INTEL SHA256 is: $s"
echo "intelsha=${s}" >> $GITHUB_OUTPUT
s=$(sha256sum arm.zip | awk '{ print $1 }')
echo "ARM SHA256 is: $s"
echo "armsha=${s}" >> $GITHUB_OUTPUT
- name: Update Cask file
env:
SHA: ${{ steps.sha.outputs.sha }}
INTELSHA: ${{ steps.sha.outputs.intelsha }}
ARMSHA: ${{ steps.sha.outputs.armsha }}
run: |
sed -i -e "s/ version.*/ version '${GITHUB_REF:11}'/" Casks/micronaut.rb
sed -i -e "s/sha256.*/sha256 '${SHA}'/" Casks/micronaut.rb
sed -i -e "s/ sha256 arm: '.*/ sha256 arm: '${ARMSHA}',/" Casks/micronaut.rb
sed -i -e "s/ intel: '.*/ intel: '${INTELSHA}'/" Casks/micronaut.rb
cat Casks/micronaut.rb
- uses: stefanzweifel/[email protected]
with:
Expand Down
3 changes: 1 addition & 2 deletions starter-cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ sdkman {
version = project.version
hashtag = "#micronautfw"
platforms = [
// TODO: Once graal native-image works for arm OSX, we should switch to building and publishing a non-rosetta release (https://github.com/oracle/graal/issues/2666)
"MAC_ARM64":"https://github.com/micronaut-projects/micronaut-starter/releases/download/v${project.version}/mn-darwin-amd64-v${project.version}.zip",
"MAC_ARM64":"https://github.com/micronaut-projects/micronaut-starter/releases/download/v${project.version}/mn-darwin-aarch64-v${project.version}.zip",
"MAC_OSX":"https://github.com/micronaut-projects/micronaut-starter/releases/download/v${project.version}/mn-darwin-amd64-v${project.version}.zip",
"WINDOWS_64":"https://github.com/micronaut-projects/micronaut-starter/releases/download/v${project.version}/mn-win-amd64-v${project.version}.zip",
"LINUX_64":"https://github.com/micronaut-projects/micronaut-starter/releases/download/v${project.version}/mn-linux-amd64-v${project.version}.zip"
Expand Down

0 comments on commit aec9474

Please sign in to comment.