-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (152 loc) · 5.76 KB
/
release.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Huawei Inc.
#
---
name: tofu-maker-cd
on:
workflow_dispatch:
inputs:
ReleaseType:
type: choice
description: Select the version to released
options:
- Major Version
- Minor Version
- Patch Version
DEFAULT_OPENTOFU_VERSION:
type: string
description: Input the default version of OpenTofu to install
required: true
default: '1.6.0'
OPENTOFU_VERSIONS:
type: string
description: Input the multiple versions of OpenTofu to install
required: true
default: '1.6.0,1.7.0,1.8.0'
env:
BOT_USER_NAME: eclipse-xpanse-bot
BOT_EMAIL_ID: [email protected]
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
release:
runs-on: ubuntu-latest
if: github.repository == 'eclipse-xpanse/tofu-maker'
outputs:
next-version: ${{ steps.new_version.outputs.next-version }}
permissions:
contents: write
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- name: Set Up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
gpg-private-key: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
gpg-passphrase: ${{ secrets.ORG_GPG_PASSPHRASE }}
server-id: maven
- name: Set current version env variable
run: |
echo "CURRENT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed s/-SNAPSHOT/""/g)" >> $GITHUB_ENV
- name: Map input to next action
run: |
if [ "${{github.event.inputs.ReleaseType}}" = "Major Version" ]; then
echo "VERSION_FRAGMENT=major" >> $GITHUB_ENV
elif [ "${{github.event.inputs.ReleaseType}}" = "Minor Version" ]; then
echo "VERSION_FRAGMENT=feature" >> $GITHUB_ENV
elif [ "${{github.event.inputs.ReleaseType}}" = "Patch Version" ]; then
echo "VERSION_FRAGMENT=bug" >> $GITHUB_ENV
else
echo "No matching feature type found"
fi
- name: Set next development version environment variable
id: new_version
uses: christian-draeger/[email protected]
with:
current-version: ${{ env.CURRENT_VERSION }}
version-fragment: ${{ env.VERSION_FRAGMENT }}
- name: Update POMs to version to be released
run: mvn versions:set -DnewVersion=${{ steps.new_version.outputs.next-version }} -DgenerateBackupPoms=false
- name: Build
run: mvn clean install -DskipTests
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ env.BOT_USER_NAME }}
password: ${{ secrets.BOT_GITHUB_DOCKER_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/[email protected]
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Build Docker Image and Push
uses: docker/[email protected]
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest,${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.new_version.outputs.next-version }}
labels: ${{ steps.meta.outputs.labels }}
provenance: false
build-args: |
DEFAULT_OPENTOFU_VERSION=${{ github.event.inputs.DEFAULT_OPENTOFU_VERSION }}
OPENTOFU_VERSIONS=${{ github.event.inputs.OPENTOFU_VERSIONS }}
- name: Push POM updates with release version
uses: EndBug/add-and-commit@v9
with:
message: "[GitHub Action] Update release version"
author_name: ${{ env.BOT_USER_NAME }}
committer_name: ${{ env.BOT_USER_NAME }}
author_email: ${{ env.BOT_EMAIL_ID }}
committer_email: ${{ env.BOT_EMAIL_ID }}
- name: Release new version on GitHub
env:
JRELEASER_GPG_PASSPHRASE: ${{ secrets.ORG_GPG_PASSPHRASE }}
JRELEASER_GPG_SECRET_KEY: ${{ secrets.ORG_GPG_PRIVATE_KEY }}
JRELEASER_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JRELEASER_GPG_PUBLIC_KEY: ${{ secrets.ORG_GPG_PUBLIC_KEY }}
JRELEASER_PROJECT_VERSION: ${{ steps.new_version.outputs.next-version }}
uses: jreleaser/release-action@v2
with:
arguments: release
- name: Upload JReleaser release output
if: always()
uses: actions/upload-artifact@v4
with:
name: jreleaser-release
path: |
out/jreleaser/trace.log
out/jreleaser/output.properties
prepare-for-next-development-cycle:
runs-on: ubuntu-latest
if: github.repository == 'eclipse-xpanse/tofu-maker'
needs: release
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
token: ${{ secrets.BOT_GITHUB_TOKEN }}
- name: Update next development version in POMs
run: mvn versions:set -DnewVersion=${{ needs.release.outputs.next-version }}-SNAPSHOT -DgenerateBackupPoms=false
- name: Push POM updates for next development cycle
uses: EndBug/add-and-commit@v9
with:
message: "[GitHub Action] Prepare for next development cycle"
author_name: ${{ env.BOT_USER_NAME }}
committer_name: ${{ env.BOT_USER_NAME }}
author_email: ${{ env.BOT_EMAIL_ID }}
committer_email: ${{ env.BOT_EMAIL_ID }}