[#4] Refactor workflow #33
Workflow file for this run
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: Build and Release an SDK Generator | |
on: | |
push: | |
branches: | |
- main | |
# FIXME drop this!! | |
pull_request: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
build-jar: | |
name: Build jar | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup Java 11 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 11 | |
- name: Setup Clojure | |
uses: DeLaGuardo/setup-clojure@12.5 | |
with: | |
cli: latest | |
- name: Cache clojure dependencies | |
uses: actions/cache@v4 | |
with: | |
path: ~/.m2/repository | |
key: cljdeps-${{ hashFiles('**/deps.edn') }} | |
restore-keys: cljdeps- | |
- name: Run tests | |
run: clojure -M:test -m kaocha.runner | |
- name: Build uberjar | |
run: clojure -T:build uberjar :jar-name aidbox-sdk | |
- name: Upload jar artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-jar | |
path: target/aidbox-sdk.jar | |
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- # | |
build-native: | |
name: Build for ${{ matrix.os }} | |
runs-on: ${{ matrix.os }} | |
needs: build-jar | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- windows-latest | |
- macos-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download jar artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-jar | |
path: ./ | |
- name: Setup GraalVM | |
uses: graalvm/setup-graalvm@v1 | |
with: | |
java-version: "21" | |
distribution: "graalvm" | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
native-image-job-reports: "true" | |
- name: Compile to native binary | |
run: | | |
make compile_native_image project_dir=${{ github.workspace }} jar_path=aidbox-sdk.jar image_name=aidbox-sdk-${{ matrix.os }} | |
chmod +x aidbox-sdk-${{ matrix.os }} | |
- name: Upload amd64 binary artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: build-${{ matrix.os }} | |
path: ./aidbox-sdk-* | |
# -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- # | |
create-release: | |
name: Release new version | |
runs-on: ubuntu-latest | |
needs: [build-jar, build-native] | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
pattern: build-* | |
path: release/ | |
merge-multiple: true | |
- name: Fetch all tags | |
run: git fetch --tags | |
- name: Determine next version | |
id: next_version | |
run: | | |
# Get the latest tag | |
latest_tag=$(git describe --tags `git rev-list --tags --max-count=1`) | |
echo "Latest tag: $latest_tag" | |
if [ -z "$latest_tag" ]; then | |
next_version="v1" | |
else | |
# Parse the version number | |
IFS='.' read -r -a version_parts <<< "${latest_tag:1}" | |
major=${version_parts[0]} | |
minor=${version_parts[1]} | |
patch=${version_parts[2]} | |
# Increment the patch version | |
patch=$((patch + 1)) | |
next_version="v$major.$minor.$patch" | |
fi | |
echo "Next version: $next_version" | |
echo "tag=$next_version" >> $GITHUB_OUTPUT | |
- name: Create a new tag | |
run: | | |
git tag ${{ steps.next_version.outputs.tag }} | |
git push origin ${{ steps.next_version.outputs.tag }} | |
# FIXME this action is archived | |
- name: Create Github Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.next_version.outputs.tag }} | |
release_name: Release ${{ steps.next_version.outputs.tag }} | |
draft: false | |
prerelease: false | |
# FIXME this action is archived | |
# FIXME do not enumarote files in reales manually | |
- name: Upload Release Asset (jar) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: release/aidbox-sdk.jar | |
asset_name: aidbox-sdk.jar | |
asset_content_type: application/java-archive | |
# FIXME this action is archived | |
- name: Upload Release Asset (amd64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: release/aidbox-sdk-ubuntu-latest | |
asset_name: aidbox-sdk-linux | |
asset_content_type: application/octet-stream | |
# FIXME this action is archived | |
- name: Upload Release Asset (arm64) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: release/aidbox-sdk-macos-latest | |
asset_name: aidbox-sdk-macos-m1 | |
asset_content_type: application/octet-stream | |
# FIXME this action is archived | |
- name: Upload Release Assets (Windows) | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
asset_path: release/aidbox-sdk-windows-latest.exe | |
asset_name: aidbox-sdk-windows.exe | |
asset_content_type: application/octet-stream |