-
Notifications
You must be signed in to change notification settings - Fork 0
117 lines (105 loc) · 3.53 KB
/
Copy pathjava-release.yaml
File metadata and controls
117 lines (105 loc) · 3.53 KB
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
name: Java Release
on:
workflow_call:
inputs:
version:
description: Version to release
type: string
required: true
development_version:
description: Next version to set in pom.xml after release. Suffix "-SNAPSHOT" is added automatically.
type: string
required: true
java_version:
description: Java version to use with the setup-java action
type: string
required: true
update_manifests:
description: Whether to update Kubernetes manifests. Requires setting an IMAGE_NAME variable in your repository.
type: boolean
required: false
default: false
jobs:
prepare-release:
name: Prepare release
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
packages: write
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up Java build environment
uses: actions/setup-java@v5
with:
distribution: 'temurin'
java-version: ${{ inputs.java_version }}
cache: 'maven'
- name: Set up Git
run: |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Update CHANGELOG.md
id: update_changelog
uses: thomaseizinger/keep-a-changelog-new-release@3.1.0
with:
tag: v${{ inputs.version }}
- name: Commit CHANGELOG.md
run: |
git add CHANGELOG.md
git commit -m "Add version ${VERSION} to CHANGELOG.md"
env:
VERSION: ${{ inputs.version }}
- name: Prepare Maven release
run: |
mvn -B \
-Darguments=-DskipTests \
-DautoVersionSubmodules=true \
-DreleaseVersion="$VERSION" \
-DscmReleaseCommitComment="Release version $VERSION" \
-DdevelopmentVersion="${DEV_VERSION}-SNAPSHOT" \
-DscmDevelopmentCommitComment="Next development version - $DEV_VERSION" \
-Dtag="v${VERSION}" \
-Dusername=${{ github.actor }} \
-Dpassword=${{ secrets.GITHUB_TOKEN }} \
release:prepare
env:
VERSION: ${{ inputs.version }}
DEV_VERSION: ${{ inputs.development_version }}
- name: Create GitHub release
uses: softprops/action-gh-release@v3
with:
body: ${{ steps.update_changelog.outputs.release-notes }}
draft: false
prerelease: false
name: ${{ inputs.version }}
tag_name: v${{ inputs.version }}
generate_release_notes: false
- name: Update Kubernetes manifests
if: ${{ inputs.update_manifests }}
uses: fjogeleit/yaml-update-action@v0.17.0
with:
changes: |
{
"k8s/prod/deployment.yaml": {
"spec.template.spec.containers[0].image": "${{ vars.IMAGE_NAME }}:${{ inputs.version }}"
},
"k8s/stage/deployment.yaml": {
"spec.template.spec.containers[0].image": "${{ vars.IMAGE_NAME }}:${{ inputs.version }}"
}
}
branch: main
commitChange: true
message: "Update Kubernetes manifests for release ${{ inputs.version }}"
- name: Build release artifacts
run: |
gh workflow run build.yaml --ref "v${VERSION}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ inputs.version }}
- name: Build snapshot artifacts
run: |
gh workflow run build.yaml --ref main
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}