-
Notifications
You must be signed in to change notification settings - Fork 0
135 lines (129 loc) · 5.28 KB
/
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
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
name: Release Pipeline
run-name: "Releasing ${{ github.event.repository.name }} #${{github.run_number}}"
on:
workflow_dispatch
jobs:
initialization:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref_name == 'refs/heads/master'
outputs:
SNAPSHOT_VERSION: ${{steps.newSnapshotVersion.outputs.SnapshotVersion}}
RELEASE_VERSION: ${{steps.splitVersion.outputs._0}}
env:
SNAPSHOTVERSION: ""
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Downloading Java
uses: actions/setup-java@v4
with:
java-version: '11'
distribution: 'temurin'
- name: Get Current Version
run: |
echo "POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- name: Print Version
run: echo ${{env.POM_VERSION}}
- name: Verify Is SNAPSHOT Version
if: ${{ !contains(env.POM_VERSION, '-SNAPSHOT')}}
run: |
echo "ERROR: Version is set to incompatible version ${{env.POM_VERSION}}. Only SNAPSHOT development versions can be converted to a release version."
exit 1
- name: Split version code
uses: xom9ikk/split@v1
id: splitVersion
with:
string: ${{env.POM_VERSION}}
separator: -SNAPSHOT
limit: -1
- name: Split version code - Minor
uses: xom9ikk/split@v1
id: splitVersionMinor
with:
string: ${{steps.splitVersion.outputs._0}}
separator: .
limit: -1
- name: Increment Snapshot Version
id: newSnapshotVersion
run: |
echo "SnapshotVersion=${{steps.splitVersionMinor.outputs._0}}.$((${{steps.splitVersionMinor.outputs._1}} + 1)).${{steps.splitVersionMinor.outputs._2}}-SNAPSHOT" >> $GITHUB_OUTPUT
- name: Print Versions
run: |
echo " Snapshot Version -- ${{steps.newSnapshotVersion.outputs.SnapshotVersion}}"
echo " Release Version -- ${{steps.splitVersion.outputs._0}}"
set_build_and_tag_release:
runs-on: ubuntu-latest
needs: initialization
permissions:
contents: write
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Downloading Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set Release Version
run: mvn -B versions:set -DnewVersion=${{needs.initialization.outputs.RELEASE_VERSION}} -DgenerateBackupPoms=false
- name: Build Release Version
run: mvn -version mvn clean install
- name: Create tag
uses: actions/github-script@v5
with:
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'refs/tags/${{needs.initialization.outputs.RELEASE_VERSION}}',
sha: context.sha
})
set_dev_release:
runs-on: ubuntu-latest
needs:
- initialization
- set_build_and_tag_release
permissions:
contents: write
steps:
- name: Checkout Code Repository
uses: actions/checkout@v4
- name: Downloading Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Set Dev Version
run: mvn -B versions:set -DnewVersion=${{needs.initialization.outputs.SNAPSHOT_VERSION}} -DgenerateBackupPoms=false
- name: Commit & Push
run: |
git add .
git config user.name fda_shield_omoruyi
git config user.email [email protected]
git commit -m 'Set next dev version to ${{needs.initialization.outputs.SNAPSHOT_VERSION}}'
git push origin HEAD:main
git push --tags origin
create_release:
name: Create Release
needs:
- initialization
- set_build_and_tag_release
- set_dev_release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
- name: Create Release
id: create_release
uses: actions/create-release@latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{needs.initialization.outputs.RELEASE_VERSION}}
release_name: Release ${{needs.initialization.outputs.RELEASE_VERSION}}
body: |
Changes in this Release
- First Change
- Second Change
draft: false
prerelease: false