Skip to content

Create release

Create release #4

Workflow file for this run

name: Create release
# Creating maven and github release
on:
workflow_dispatch:
inputs:
release-version: # id of input
description: "override default release version e.g. with 0.1.0-1"
required: false
permissions:
contents: write
env:
RELEASE_VERSION: ${{ github.event.inputs.release-version }}
IMAGE_NAME: odp-adapter
DOCKERHUB_USERNAME: starwit
DOCKERHUB_ORG: starwitorg
jobs:
build:
name: "Creating maven and github release"
runs-on: [self-hosted, linux, X64]
steps:
- name: Install GH CLI
uses: dev-hanz-ops/[email protected]
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Set up Maven
uses: stCarolas/setup-maven@v5
with:
maven-version: 3.9.2
- name: checkout
uses: actions/checkout@v4
with:
fetch-depth: '0'
- name: Maven release pepare
run: |
git config --global user.email "[email protected]"
git config --global user.name "Starwit"
if [ ! -z "${{ env.RELEASE_VERSION }}" ]
then
echo "new version manually set to ${{ env.RELEASE_VERSION }}"
mvn -B build-helper:parse-version versions:set -DnewVersion=${{ env.RELEASE_VERSION }}-SNAPSHOT versions:commit --settings .github/workflows/settings.xml --file pom.xml
fi
echo "mvn generate-sources --file pom.xml"
mvn generate-sources --file pom.xml
echo "git add ."
git add .
modifications=$(git status | grep "modified" || true)
if [ ! -z "$modifications" ]
then
echo "modifications found: $modifications"
git commit -m "modified changelog"
git push
fi
mvn -B release:clean release:prepare -Darguments="-DskipTests" --file pom.xml
mvn -B release:clean --file pom.xml
env:
CI: false
PRIVATE_REPO_USERNAME: ${{ vars.PRIVATE_REPO_USERNAME }}
MAVEN_REPO_READ: ${{ secrets.MAVEN_REPO_READ }}
- name: Get tag name
run: |
echo "TAG=$( git describe --abbrev=0 )" >> $GITHUB_ENV
- name: Create github release
run: gh release create ${{ env.TAG }} -F CHANGELOG.md
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout tag
run: |
git checkout ${{ env.TAG }}
- name: Build with Maven
run: mvn clean -B package --file pom.xml
env:
CI: false
PRIVATE_REPO_USERNAME: ${{ vars.PRIVATE_REPO_USERNAME }}
MAVEN_REPO_READ: ${{ secrets.MAVEN_REPO_READ }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
publish_docker:
name: "Build and publish docker"
needs: build
runs-on: [self-hosted, linux, X64]
steps:
- name: Get tag name
run: |
echo "TAG=$( git describe --abbrev=0 )" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./dockerfile
push: true
tags: ${{ env.DOCKERHUB_ORG }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
publish_helm:
name: "Publish helm chart"
needs: build
runs-on: [self-hosted, linux, X64]
steps:
- name: get helm
uses: azure/setup-helm@v4
- name: login to Helm registry
run: helm registry login registry-1.docker.io -u starwit -p ${{ secrets.DOCKERHUB_TOKEN }}
- name: run helm update
working-directory: target/helm/odp-adapter
run: helm dep update
- name: run helm package
working-directory: target/helm
run: helm package odp-adapter
- name: get version number
working-directory: target/helm/odp-adapter
run: |
echo "HELM_VERSION=$(grep version: Chart.yaml | head -1 | awk '{print $2}')" >> $GITHUB_ENV
- name: run helm push
working-directory: target/helm
run: helm push odp-adapter-chart-${{ env.HELM_VERSION }}.tgz oci://registry-1.docker.io/starwitorg