Skip to content

Commit 129e306

Browse files
Merge pull request #22 from OmOmofonmwan/feature/IAT-848-Release-POC
Release POC
2 parents fe07518 + 97c4ef8 commit 129e306

1 file changed

Lines changed: 136 additions & 0 deletions

File tree

.github/workflows/release_poc.yaml

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
name: Release Pipeline
2+
3+
run-name: "Releasing ${{ github.event.repository.name }} #${{github.run_number}}"
4+
5+
on:
6+
workflow_dispatch
7+
8+
jobs:
9+
initialization:
10+
runs-on: ubuntu-latest
11+
if: github.ref == 'refs/heads/main' || github.ref_name == 'refs/heads/master'
12+
outputs:
13+
SNAPSHOT_VERSION: ${{steps.newSnapshotVersion.outputs.SnapshotVersion}}
14+
RELEASE_VERSION: ${{steps.splitVersion.outputs._0}}
15+
env:
16+
SNAPSHOTVERSION: ""
17+
steps:
18+
- name: Checkout Code Repository
19+
uses: actions/checkout@v4
20+
- name: Downloading Java
21+
uses: actions/setup-java@v4
22+
with:
23+
java-version: '11'
24+
distribution: 'temurin'
25+
- name: Get Current Version
26+
run: |
27+
echo "POM_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
28+
- name: Print Version
29+
run: echo ${{env.POM_VERSION}}
30+
- name: Verify Is SNAPSHOT Version
31+
if: ${{ !contains(env.POM_VERSION, '-SNAPSHOT')}}
32+
run: |
33+
echo "ERROR: Version is set to incompatible version ${{env.POM_VERSION}}. Only SNAPSHOT development versions can be converted to a release version."
34+
exit 1
35+
- name: Split version code
36+
uses: xom9ikk/split@v1
37+
id: splitVersion
38+
with:
39+
string: ${{env.POM_VERSION}}
40+
separator: -SNAPSHOT
41+
limit: -1
42+
- name: Split version code - Minor
43+
uses: xom9ikk/split@v1
44+
id: splitVersionMinor
45+
with:
46+
string: ${{steps.splitVersion.outputs._0}}
47+
separator: .
48+
limit: -1
49+
- name: Increment Snapshot Version
50+
id: newSnapshotVersion
51+
run: |
52+
echo "SnapshotVersion=${{steps.splitVersionMinor.outputs._0}}.$((${{steps.splitVersionMinor.outputs._1}} + 1)).${{steps.splitVersionMinor.outputs._2}}-SNAPSHOT" >> $GITHUB_OUTPUT
53+
- name: Print Versions
54+
run: |
55+
echo " Snapshot Version -- ${{steps.newSnapshotVersion.outputs.SnapshotVersion}}"
56+
echo " Release Version -- ${{steps.splitVersion.outputs._0}}"
57+
58+
set_build_and_tag_release:
59+
runs-on: ubuntu-latest
60+
needs: initialization
61+
permissions:
62+
contents: write
63+
steps:
64+
- name: Checkout Code Repository
65+
uses: actions/checkout@v4
66+
- name: Downloading Java
67+
uses: actions/setup-java@v4
68+
with:
69+
java-version: '21'
70+
distribution: 'temurin'
71+
- name: Set Release Version
72+
run: mvn -B versions:set -DnewVersion=${{needs.initialization.outputs.RELEASE_VERSION}} -DgenerateBackupPoms=false
73+
- name: Build Release Version
74+
run: mvn -version mvn clean install
75+
- name: Create tag
76+
uses: actions/github-script@v5
77+
with:
78+
script: |
79+
github.rest.git.createRef({
80+
owner: context.repo.owner,
81+
repo: context.repo.repo,
82+
ref: 'refs/tags/${{needs.initialization.outputs.RELEASE_VERSION}}',
83+
sha: context.sha
84+
})
85+
86+
set_next_dev:
87+
runs-on: ubuntu-latest
88+
needs:
89+
- initialization
90+
- set_build_and_tag_release
91+
permissions:
92+
contents: write
93+
steps:
94+
- name: Checkout Code Repository
95+
uses: actions/checkout@v4
96+
- name: Downloading Java
97+
uses: actions/setup-java@v4
98+
with:
99+
java-version: '21'
100+
distribution: 'temurin'
101+
- name: Set Dev Version
102+
run: mvn -B versions:set -DnewVersion=${{needs.initialization.outputs.SNAPSHOT_VERSION}} -DgenerateBackupPoms=false
103+
- name: Commit & Push
104+
run: |
105+
git add .
106+
git config user.name fda_shield_omoruyi
107+
git config user.email oomofonmwan93@gmail.com
108+
git commit -m 'Set next dev version to ${{needs.initialization.outputs.SNAPSHOT_VERSION}}'
109+
git push origin HEAD:main
110+
git push --tags origin
111+
112+
create_release:
113+
name: Create Release
114+
permissions: write-all
115+
needs:
116+
- initialization
117+
- set_build_and_tag_release
118+
- set_next_dev
119+
runs-on: ubuntu-latest
120+
steps:
121+
- name: Checkout code
122+
uses: actions/checkout@master
123+
- name: Create Release
124+
id: create_release
125+
uses: actions/create-release@latest
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
128+
with:
129+
tag_name: ${{needs.initialization.outputs.RELEASE_VERSION}}
130+
release_name: Release ${{needs.initialization.outputs.RELEASE_VERSION}}
131+
body: |
132+
Changes in this Release
133+
- First Change
134+
- Second Change
135+
draft: false
136+
prerelease: false

0 commit comments

Comments
 (0)