Skip to content

Commit

Permalink
feat: add release pipline with build and publish trigger (#18)
Browse files Browse the repository at this point in the history
* feat: add release pipline with build and publish trigger

* chore: minor changes in ci files

* chore: add simple test scripts for ci

* fix: release job corrected branch name and upgrade packages

* chore: update action versions
  • Loading branch information
dhommen authored Jul 3, 2024
1 parent 8ad5b4e commit 934a3ab
Show file tree
Hide file tree
Showing 13 changed files with 6,919 additions and 743 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
name: Build and Publish EDC Extension
name: Build and Test
on:
push:
branches: ["main"]
paths: ["logging-house-client/**/*"]
pull_request:
branches: ["main"]

Expand All @@ -11,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
packages: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
Expand All @@ -21,18 +18,9 @@ jobs:
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
- name: Build package
if: ${{ github.ref != 'refs/heads/main' }}
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: build
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ github.token }}
- name: Publish package
if: ${{ github.ref == 'refs/heads/main' }}
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: publish
arguments: build
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ github.token }}
47 changes: 0 additions & 47 deletions .github/workflows/publish-server.yml

This file was deleted.

78 changes: 78 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build and Publish

on:
release:
types: [published]

env:
REGISTRY: ghcr.io/truzzt/mds-ap3
DOCKER_USERNAME: ${{ github.actor }}
DOCKER_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
IMAGE_TAG: ${{ github.event.release.name }}

jobs:
build-and-publish-server:
runs-on: ubuntu-latest
strategy:
matrix:
component: ['app', 'edc']

permissions:
contents: read
packages: write
id-token: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Login to GitHub Container Registry
run: echo $DOCKER_PASSWORD | docker login $REGISTRY -u $DOCKER_USERNAME --password-stdin

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build and Push Docker image
run: |
cd logging-house-server/${{ matrix.component }}
docker build -t $REGISTRY/${{ matrix.component }}:$IMAGE_TAG .
docker push $REGISTRY/${{ matrix.component }}:$IMAGE_TAG
with:
context: .
file: ./Dockerfile
push: true
tags: $REGISTRY/${{ matrix.component }}:$IMAGE_TAG
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache


build-and-publish-edc-extension:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@ccb4328a959376b642e027874838f60f8e596de3
- name: Publish
uses: gradle/gradle-build-action@749f47bda3e44aa060e82d7b3ef7e40d953bd629
with:
arguments: -Pversion=${{ env.IMAGE_TAG }} publish
env:
USERNAME: ${{ github.actor }}
TOKEN: ${{ github.token }}

24 changes: 24 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Release
on:
push:
branches:
- main

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v42
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
10 changes: 10 additions & 0 deletions .releaserc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"branches": ["+([0-9])?(.{+([0-9]),x}).x", "main"],
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/git",
"@semantic-release/github"
]
}
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ subprojects {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/truzzt/mds-ap3")
version = "0.3.2"
credentials {
username = System.getenv("USERNAME")
password = System.getenv("TOKEN")
Expand Down
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ jettyGroup=org.eclipse.jetty
jettyVersion=11.0.15

org.gradle.jvmargs=-Xmx1024m
version=0.3.2
Loading

0 comments on commit 934a3ab

Please sign in to comment.