Skip to content

Commit

Permalink
PRD-2405 CI/CD setup for publishing CLI artifacts (#1)
Browse files Browse the repository at this point in the history
* Include libcurl install step for linux runner; add macos runner

* Just build instead of build+run

* Include binary rename step in workflow

* Fix path directory

* Add additional fields; fix version

* Set hardcoded version to start with

* Set apt env vars for jreleaser release step as well

* Include additiona fields

* Set right path for picking up artifacts

* Fix names of the artifact archives

* Adjust jreleaser zip config

* Use versioning and manual release system
  • Loading branch information
Rounak Datta authored Aug 8, 2023
1 parent a18d9e7 commit 2b3753f
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 17 deletions.
34 changes: 27 additions & 7 deletions .github/workflows/publish_cli_artifacts.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
name: Publish CLI Artifacts
on:
workflow_dispatch:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*' # v0.0.1 - this syntax of tags is supported

jobs:
build_and_assemble:
strategy:
matrix:
os: [ubuntu-latest]
os: [macos-13, ubuntu-latest]
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -19,15 +21,32 @@ jobs:
java-version: '17'
distribution: 'adopt'

- name: Install prerequisites for Linux runner
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get install libcurl4-openssl-dev
- name: Build Binary
run: ./gradlew runDebugExecutableNative
run: ./gradlew linkDebugExecutableNative

- name: Rename the Linux binary appropriately
if: matrix.os == 'ubuntu-latest'
working-directory: ./build/bin/native/debugExecutable
run: |
mv cli.kexe cmdk-linux-x86_64
- name: Rename the macOS binary appropriately
if: matrix.os == 'macos-13'
working-directory: ./build/bin/native/debugExecutable
run: |
mv cli.kexe cmdk-osx-x86_64
- name: Assemble (rename etc) the binaries
uses: jreleaser/release-action@v2
with:
arguments: assemble
env:
JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }}
JRELEASER_PROJECT_VERSION: ${{ github.ref_name }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_PLATFORM_OVERRIDE: ${{ matrix.job.jreleaser_platform }}

Expand All @@ -37,7 +56,7 @@ jobs:
retention-days: 1
name: artifacts
path: |
out/jreleaser/cmdk/archive/*.zip
out/jreleaser/assemble/cmdk-cli-client/archive/*.zip
release:
needs: [ build_and_assemble ]
Expand All @@ -58,5 +77,6 @@ jobs:
with:
arguments: full-release -PartifactsDir=artifacts -PskipArchiveResolver
env:
JRELEASER_PROJECT_VERSION: ${{ needs.precheck.outputs.VERSION }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GH_PAT }}
JRELEASER_PROJECT_VERSION: ${{ github.ref_name }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_PLATFORM_OVERRIDE: ${{ matrix.job.jreleaser_platform }}
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ repositories {

kotlin {
val hostOs = System.getProperty("os.name")
val hostArch = System.getProperty("os.arch")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosArm64("native")
hostOs == "Mac OS X" && hostArch == "x86_64" -> macosX64("native")
hostOs == "Mac OS X" && (hostArch == "arm64" || hostArch == "aarch64") -> macosArm64("native")
isMingwX64 -> mingwX64("native")
hostOs == "Linux" -> linuxX64("native")
else -> throw GradleException("Host OS is not supported: $hostOs")
Expand Down
20 changes: 11 additions & 9 deletions jreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ project:
description: cmdk is the command line client to interact with the CommandK platform
links:
homepage: https://github.com/commandk-dev/cli
authors:
- Rahul Jain
copyright: CommandK, Inc
website: https://commandk.dev
license: APACHE-2.0
docsUrl: https://github.com/commandk-dev/java-sdk
java:
groupId: dev.commandk
version: 17
Expand Down Expand Up @@ -31,14 +37,8 @@ assemble:
active: ALWAYS
attachPlatform: true
fileSets:
- input: 'build/bin/native/releaseExecutable'
output: 'bin'
includes: [ 'cli.kexe' ]
mapper:
type: 'identity'
includes:
- pattern: 'cli.kexe'
to: 'cmdk-${platform}'
- input: 'build/bin/native/debugExecutable'
includes: [ 'cmdk-*' ]

environment:
properties:
Expand All @@ -47,5 +47,7 @@ environment:
distributions:
cmdk:
artifacts:
- path: "{{artifactsDir}}/cmdk-{{platform}}"
- path: "{{artifactsDir}}/cmdk-cli-client-{{projectVersion}}-linux-x86_64.zip"
platform: "linux-x86_64"
- path: "{{artifactsDir}}/cmdk-cli-client-{{projectVersion}}-osx-x86_64.zip"
platform: "osx-x86_64"

0 comments on commit 2b3753f

Please sign in to comment.