-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (86 loc) · 2.97 KB
/
reusable_release_poc.yaml
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
name: Reusable Release Workflow
run-name: "Releasing ${{ github.event.repository.name }} #${{github.run_number}}"
# Trigger workflow manually
on:
workflow_call:
inputs:
snapshot_version:
type: string
required: true
release_version:
type: string
required: true
release_message:
type: string
required: false
# Define environment parameters
env:
BRANCH_NAME: ${{github.ref_name}}
TRUNK_BRANCH_NAME: main
RELEASE_MESSAGE: ${{github.event.inputs.release_message}}
# Define jobs within the workflow
jobs:
#Setting versioning for build and tags
set_build_and_tag_release_and_set_next_dev_version:
name: Set, Build, Tag Release Version & Set Next Version
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Setup Maven Action
uses: s4u/[email protected]
with:
checkout-fetch-depth: 0
java-version: 21
java-distribution: adopt
maven-version: 3.9.0
- name: Set Release Version
run: |
mvn -B versions:set \
-DnewVersion=${{inputs.release_version}} \
-DgenerateBackupPoms=false
- name: Build Release Version
run: |
mvn -version
mvn clean install
- name: Create tag
run: |
git remote set-url origin https://git:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git
git config user.name "Cloud User"
git add .
git commit -m 'Release ${{inputs.release_version}}'
git tag -a ${{inputs.release_version}} -m '${{inputs.release_version}}' --force
- name: Set Dev Version
run: |
mvn -B versions:set \
-DnewVersion=${{inputs.snapshot_version}} \
-DgenerateBackupPoms=false
- name: Commit & Push
run: |
git add .
git commit -m 'Set next dev version to ${{inputs.snapshot_version}}'
git push origin HEAD:main
git push --tags origin
# Creating a release
create_release:
name: Create Release
permissions: write-all
needs:
- set_build_and_tag_release_and_set_next_dev_version
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Modify Release Message
if: inputs.release_message == ''
run: echo "RELEASE_MESSAGE=Release ${{inputs.release_version}}" >> $GITHUB_ENV
- name: Create Release
id: create_release
run: |
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer ${{secrets.GITHUB_TOKEN}}" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/${{github.repository}}/releases \
-d '{"tag_name":"${{inputs.release_version}}","name":"${{inputs.release_version}}","body":"${{env.RELEASE_MESSAGE}}","draft":false,"prerelease":false,"generate_release_notes":false}'