-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (128 loc) · 4.44 KB
/
createRelease.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
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 }}
MAVEN_GPG_PASSPHRASE: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
MAVEN_GPG_KEY: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
- 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: debug
run: |
find .
- name: run helm push
working-directory: target/helm
run: helm push odp-adapter-chart-${{ env.HELM_VERSION }}.tgz oci://registry-1.docker.io/starwitorg