Skip to content

Commit

Permalink
build(ci): add automated release management (#962)
Browse files Browse the repository at this point in the history
This removes the need to run ./local-dev/bump.sh to prepare for new version releases. By default 0.0.0-development or just 0.0.0 is statically present in some files but it's replaced by the corresponding version during the workflow run.

The release workflow will be triggered on any commit tagged with prefix v and the semantic version like v0.0.0-development.

The pipeline process generates:

docker images with the matching semantic version
lh-server:0.0.0-development
lh-dashboard:0.0.0-development
etc
SDKs with semantic version
sdk-java
sdk-python
sdk-js
sdk-go module with git tag
lhctl version
lh-server ServerVersionResponse{majorVersion, minorVersion, patchVersion, preReleaseIdentifier}
  • Loading branch information
mijailr authored Aug 23, 2024
1 parent ae2c121 commit e4d42b0
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 130 deletions.
101 changes: 0 additions & 101 deletions .github/actions/publish-image/action.yml

This file was deleted.

12 changes: 6 additions & 6 deletions .github/workflows/branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
path: server/build/libs/server-*-all.jar

- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-server
dockerfile: docker/server/Dockerfile
Expand Down Expand Up @@ -69,7 +69,7 @@ jobs:
path: canary/build/libs/canary-*-all.jar

- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-canary
dockerfile: docker/canary/Dockerfile
Expand All @@ -83,7 +83,7 @@ jobs:
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

Expand All @@ -94,7 +94,7 @@ jobs:
npm run build
- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-dashboard
dockerfile: docker/dashboard/Dockerfile
Expand All @@ -110,7 +110,7 @@ jobs:
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

Expand All @@ -127,7 +127,7 @@ jobs:
path: server/build/libs/

- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-standalone
dockerfile: docker/standalone/Dockerfile
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
run: pwd

- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20
cache-dependency-path: ./docs/package-lock.json
Expand Down
28 changes: 19 additions & 9 deletions .github/workflows/publish-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ run-name: Publish Docker Images
on:
workflow_call:
permissions:
packages: write
contents: read
packages: write
contents: read
jobs:
build-server:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -40,11 +40,13 @@ jobs:
path: server/build/libs/

- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-server
dockerfile: docker/server/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=semver,pattern={{version}}
lh-canary:
runs-on: ubuntu-latest
Expand All @@ -67,11 +69,13 @@ jobs:
path: canary/build/libs/canary-*-all.jar

- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-canary
dockerfile: docker/canary/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=semver,pattern={{version}}
lhctl:
runs-on: ubuntu-latest
Expand All @@ -82,11 +86,13 @@ jobs:
uses: actions/checkout@v4

- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lhctl
dockerfile: docker/lhctl/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=semver,pattern={{version}}
lh-dashboard:
runs-on: ubuntu-latest
Expand All @@ -95,7 +101,7 @@ jobs:
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

Expand All @@ -106,11 +112,13 @@ jobs:
npm run build
- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-dashboard
dockerfile: docker/dashboard/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=semver,pattern={{version}}
lh-standalone:
runs-on: ubuntu-latest
Expand All @@ -121,7 +129,7 @@ jobs:
uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 20

Expand All @@ -138,8 +146,10 @@ jobs:
path: server/build/libs/

- name: Build and Publish
uses: ./.github/actions/publish-image
uses: littlehorse-enterprises/publish-image@v1
with:
image-name: lh-standalone
dockerfile: docker/standalone/Dockerfile
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=semver,pattern={{version}}
39 changes: 36 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,37 +3,59 @@ run-name: Release ${{ github.ref_name }}
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+*" # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- "v[0-9]+.[0-9]+.[0-9]+*"

permissions:
packages: write
contents: write
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.set_tag.outputs.tag }}
steps:
- name: Set Tag
id: set_tag
run: |
echo "tag=$(echo $GITHUB_REF | sed -n 's/refs\/tags\/v//p')" >> $GITHUB_OUTPUT
publish-docker:
uses: ./.github/workflows/publish-docker.yml

sdk-java:
runs-on: ubuntu-latest
needs:
- publish-docker
- prepare
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "corretto"
java-version: "11"

- name: Dump version
env:
TAG: ${{ needs.prepare.outputs.tag }}
run: sed -i "s/version=.*/version=${TAG}/g" gradle.properties

- name: Tests
run: ./gradlew sdk-java:test

- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}

- name: Generate KeyRing
run: |
gpg --keyring secring.gpg --export-secret-keys --passphrase ${{ secrets.GPG_PASSPHRASE }} --batch --yes --pinentry-mode=loopback > ~/.gnupg/secring.gpg
ls ~/.gnupg/
- name: Publish
run: |
./gradlew sdk-java:publish -Psigning.secretKeyRingFile=/home/runner/.gnupg/secring.gpg -Psigning.password=${{ secrets.GPG_PASSPHRASE }} -Psigning.keyId=${{ vars.GPG_KEY_ID }} -PossrhUsername=${{ secrets.OSSRH_USERNAME }} -PossrhPassword=${{ secrets.OSSRH_PASSWORD }}
Expand All @@ -43,23 +65,33 @@ jobs:
runs-on: ubuntu-latest
needs:
- publish-docker
- prepare
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Dump version
env:
TAG: ${{ needs.prepare.outputs.tag }}
run: sed -i "s/version = '.*'/version = '${TAG}'/g" sdk-python/pyproject.toml

- name: Set up Python
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: "3.9"

- name: Install Dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
pip install poetry
- name: Tests
working-directory: ./sdk-python
run: |
poetry install
poetry run python -m unittest -v
poetry build
- name: Publish Package
uses: pypa/[email protected]
with:
Expand All @@ -71,6 +103,7 @@ jobs:
runs-on: ubuntu-latest
needs:
- publish-docker
- prepare
env:
working-directory: ./sdk-js
steps:
Expand All @@ -96,7 +129,7 @@ jobs:
- name: Use tag
working-directory: ${{env.working-directory}}
env:
TAG: ${{ github.ref_name }}
TAG: ${{ needs.prepare.outputs.tag }}
run: cat package.json | jq -r ".version = \"${TAG}\"" | tee package.json

- name: Build
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Dependencies
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.10.1
version=0.0.0-development
group=io.littlehorse
kafkaVersion=3.8.0
lombokVersion=1.18.28
Expand Down
Loading

0 comments on commit e4d42b0

Please sign in to comment.