From e21f95d1096742d3cb6691b610ca71c76f73f492 Mon Sep 17 00:00:00 2001 From: baldm Date: Tue, 16 Jul 2024 15:50:28 +0200 Subject: [PATCH 1/6] Create publish-arm.yaml --- .github/workflows/publish-arm.yaml | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/publish-arm.yaml diff --git a/.github/workflows/publish-arm.yaml b/.github/workflows/publish-arm.yaml new file mode 100644 index 0000000..67d43a2 --- /dev/null +++ b/.github/workflows/publish-arm.yaml @@ -0,0 +1,40 @@ +name: Build binary - arm + +on: + push: + tags: + - 'v*' + +permissions: + contents: write + +jobs: + build: + runs-on: self-hosted-arm64 + steps: + - uses: actions/checkout@v4 + - name: Set up JDK + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'adopt' + cache: 'gradle' + - uses: actions/cache@v4 + with: + path: "/home/runner/.konan" + key: ${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }} + - name: Install dependencies + run: | + sudo apt update + sudo apt install libcurl4-openssl-dev + - name: Build with Gradle + run: ./gradlew commonBinaries + - name: Move and apply correct permissions to binary + run: | + cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli + chmod +x ./slack-notifier-cli + # - name: Upload executable + # uses: actions/upload-artifact@v4 + # with: + # name: slack-notifier-cli-arm + # path: slack-notifier-cli-arm \ No newline at end of file From 81469b391c8ddfda35f598913e1dcac5a759b7ec Mon Sep 17 00:00:00 2001 From: baldm Date: Tue, 16 Jul 2024 16:27:14 +0200 Subject: [PATCH 2/6] Change existing release instead of generating a new one --- .github/workflows/publish.yaml | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index f1c093a..abbfca3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -10,7 +10,10 @@ permissions: jobs: build: - runs-on: ubuntu-latest + strategy: + matrix: + machine: [ubuntu-latest, self-hosted-arm64] + runs-on: ${{ matrix.machine }} steps: - uses: actions/checkout@v4 - name: Set up JDK @@ -29,15 +32,20 @@ jobs: sudo apt install libcurl4-openssl-dev - name: Build with Gradle run: ./gradlew commonBinaries - - name: Move and apply correct permissions to binary + - name: Rename executable based on runner run: | - cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli - chmod +x ./slack-notifier-cli + if [ "${{ matrix.machine }}" == "self-hosted-arm64" ]; then + cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli-arm + chmod +x ./slack-notifier-cli-arm + else + cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli + chmod +x ./slack-notifier-cli + fi - name: Upload executable uses: actions/upload-artifact@v4 with: - name: slack-notifier-cli - path: slack-notifier-cli + name: ${{ matrix.machine == 'self-hosted-arm64' && 'slack-notifier-cli-arm' || 'slack-notifier-cli' }} + path: ${{ matrix.machine == 'self-hosted-arm64' && 'slack-notifier-cli-arm' || 'slack-notifier-cli' }} change-log: runs-on: ubuntu-latest needs: build @@ -62,6 +70,10 @@ jobs: uses: actions/download-artifact@v4 with: name: slack-notifier-cli + - name: Download a single artifact for arm + uses: actions/download-artifact@v4 + with: + name: slack-notifier-cli-arm - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: @@ -70,3 +82,11 @@ jobs: asset_name: slack-notifier-cli tag: ${{ github.ref }} overwrite: true + - name: Upload binaries to release + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: slack-notifier-cli-arm + asset_name: slack-notifier-cli-arm + tag: ${{ github.ref }} + overwrite: true \ No newline at end of file From 2dd8ce12c22f361c815f653486bd1b60a058938c Mon Sep 17 00:00:00 2001 From: baldm Date: Tue, 16 Jul 2024 16:27:21 +0200 Subject: [PATCH 3/6] Delete publish-arm.yaml --- .github/workflows/publish-arm.yaml | 40 ------------------------------ 1 file changed, 40 deletions(-) delete mode 100644 .github/workflows/publish-arm.yaml diff --git a/.github/workflows/publish-arm.yaml b/.github/workflows/publish-arm.yaml deleted file mode 100644 index 67d43a2..0000000 --- a/.github/workflows/publish-arm.yaml +++ /dev/null @@ -1,40 +0,0 @@ -name: Build binary - arm - -on: - push: - tags: - - 'v*' - -permissions: - contents: write - -jobs: - build: - runs-on: self-hosted-arm64 - steps: - - uses: actions/checkout@v4 - - name: Set up JDK - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'adopt' - cache: 'gradle' - - uses: actions/cache@v4 - with: - path: "/home/runner/.konan" - key: ${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }} - - name: Install dependencies - run: | - sudo apt update - sudo apt install libcurl4-openssl-dev - - name: Build with Gradle - run: ./gradlew commonBinaries - - name: Move and apply correct permissions to binary - run: | - cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli - chmod +x ./slack-notifier-cli - # - name: Upload executable - # uses: actions/upload-artifact@v4 - # with: - # name: slack-notifier-cli-arm - # path: slack-notifier-cli-arm \ No newline at end of file From e0f56c15f7e7fb715ab3b5b73124316796079f33 Mon Sep 17 00:00:00 2001 From: baldm Date: Tue, 16 Jul 2024 16:50:50 +0200 Subject: [PATCH 4/6] Update publish.yaml --- .github/workflows/publish.yaml | 38 +++++++++++----------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index abbfca3..709fe83 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -32,22 +32,20 @@ jobs: sudo apt install libcurl4-openssl-dev - name: Build with Gradle run: ./gradlew commonBinaries - - name: Rename executable based on runner + - name: Move and apply correct permissions to binary run: | - if [ "${{ matrix.machine }}" == "self-hosted-arm64" ]; then - cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli-arm - chmod +x ./slack-notifier-cli-arm - else - cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli - chmod +x ./slack-notifier-cli - fi + cp build/bin/common/releaseExecutable/slack-notifier-cli.kexe ./slack-notifier-cli-${{ runner.arch }} + chmod +x ./slack-notifier-cli-${{ runner.arch }} - name: Upload executable uses: actions/upload-artifact@v4 with: - name: ${{ matrix.machine == 'self-hosted-arm64' && 'slack-notifier-cli-arm' || 'slack-notifier-cli' }} - path: ${{ matrix.machine == 'self-hosted-arm64' && 'slack-notifier-cli-arm' || 'slack-notifier-cli' }} + name: slack-notifier-cli-${{ runner.arch }} + path: slack-notifier-cli-${{ runner.arch }} change-log: - runs-on: ubuntu-latest + strategy: + matrix: + machine: [ubuntu-latest, self-hosted-arm64] + runs-on: ${{ matrix.machine }} needs: build timeout-minutes: 5 steps: @@ -69,24 +67,12 @@ jobs: - name: Download a single artifact uses: actions/download-artifact@v4 with: - name: slack-notifier-cli - - name: Download a single artifact for arm - uses: actions/download-artifact@v4 - with: - name: slack-notifier-cli-arm + name: slack-notifier-cli-${{ runner.arch }} - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} - file: slack-notifier-cli - asset_name: slack-notifier-cli + file: slack-notifier-cli-${{ runner.arch }} + asset_name: slack-notifier-cli-${{ runner.arch }} tag: ${{ github.ref }} overwrite: true - - name: Upload binaries to release - uses: svenstaro/upload-release-action@v2 - with: - repo_token: ${{ secrets.GITHUB_TOKEN }} - file: slack-notifier-cli-arm - asset_name: slack-notifier-cli-arm - tag: ${{ github.ref }} - overwrite: true \ No newline at end of file From 773e5d9706306a213048967e49be69970040d6dd Mon Sep 17 00:00:00 2001 From: Anders Nickelsen Date: Thu, 19 Sep 2024 11:13:26 +0200 Subject: [PATCH 5/6] Cross compile cli --- .github/workflows/publish.yaml | 4 ++-- build.gradle.kts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 709fe83..6ed38c3 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -28,8 +28,8 @@ jobs: key: ${{ runner.os }}-${{ hashFiles('**/build.gradle.kts') }} - name: Install dependencies run: | - sudo apt update - sudo apt install libcurl4-openssl-dev + sudo apt -y update + sudo apt -y install libcurl4-openssl-dev - name: Build with Gradle run: ./gradlew commonBinaries - name: Move and apply correct permissions to binary diff --git a/build.gradle.kts b/build.gradle.kts index f16d4b4..951413f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,12 +17,14 @@ defaultTasks("commonBinaries") kotlin { val hostOs = System.getProperty("os.name") + val hostArch = System.getProperty("os.arch") // Cross Compilation val commonTarget = when { hostOs == "Mac OS X" -> macosArm64("common") - hostOs == "Linux" -> linuxX64("common") + hostOs == "Linux" && hostArch == "aarch64" -> linuxArm64("common") + hostOs == "Linux" && hostArch == "amd64" -> linuxX64("common") hostOs.startsWith("Windows") -> mingwX64("common") else -> throw GradleException("Host OS is not supported in Kotlin/Native.") } From c727e77a779b8baa8b8b8e38a3eedc12714bceb2 Mon Sep 17 00:00:00 2001 From: Anders Nickelsen Date: Thu, 19 Sep 2024 11:19:14 +0200 Subject: [PATCH 6/6] Improve copy --- .github/workflows/publish.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 6ed38c3..4c5550a 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -41,7 +41,7 @@ jobs: with: name: slack-notifier-cli-${{ runner.arch }} path: slack-notifier-cli-${{ runner.arch }} - change-log: + publish: strategy: matrix: machine: [ubuntu-latest, self-hosted-arm64] @@ -64,11 +64,11 @@ jobs: output: "console" slack-token: ${{ secrets.SLACK_APP_TOKEN }} slack-channel: "#releases" - - name: Download a single artifact + - name: Download executable uses: actions/download-artifact@v4 with: name: slack-notifier-cli-${{ runner.arch }} - - name: Upload binaries to release + - name: Publish executable as release asset uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }}