Repository navigation
Expand file tree
/
Copy pathjava-roll-version-and-release.yaml
More file actions
113 lines (110 loc) · 4.81 KB
/
Copy pathjava-roll-version-and-release.yaml
File metadata and controls
113 lines (110 loc) · 4.81 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
# A workflow to find the current version from pom and then commit the release version (with tag) and the next dev cycle version
name: Roll maven version and release
on:
workflow_call:
jobs:
extract:
name: extract-version
runs-on:
- self-hosted
- java
outputs:
major: ${{ steps.major.outputs.major }}
minor: ${{ steps.minor.outputs.minor }}
patch: ${{ steps.patch.outputs.patch }}
steps:
- uses: actions/checkout@v6
- id: major
run: |
echo "major=$(mvn --quiet build-helper:parse-version help:evaluate -Dexpression=parsedVersion.majorVersion -DforceStdout --no-transfer-progress)" >> $GITHUB_OUTPUT
- id: minor
run: |
echo "minor=$(mvn --quiet build-helper:parse-version help:evaluate -Dexpression=parsedVersion.minorVersion -DforceStdout --no-transfer-progress)" >> $GITHUB_OUTPUT
- id: patch
run: |
echo "patch=$(mvn --quiet build-helper:parse-version help:evaluate -Dexpression=parsedVersion.incrementalVersion -DforceStdout --no-transfer-progress)" >> $GITHUB_OUTPUT
- id: echo-version
run: |
echo ${{steps.major.outputs.major}}.${{steps.minor.outputs.minor}}.${{steps.patch.outputs.patch}}
update-version-commit:
needs: extract
env:
NEW_VERSION: ${{ needs.extract.outputs.major }}.${{ needs.extract.outputs.minor }}.${{ needs.extract.outputs.patch }}
runs-on:
- self-hosted
- java
steps:
- run: echo "NEW_VERSION=$NEW_VERSION"
- uses: actions/checkout@v6
- name: Setup git author information
run: |
git config user.name RCSBSystem
git config user.email it@rcsb.org
- run: mvn --version
- name: Set version
run: mvn versions:set -DnewVersion=$NEW_VERSION --no-transfer-progress
- name: Commit and tag new version (release commit)
run: |
git add $(find . -name "pom.xml")
git commit -m "[actions] Updated version in pom.xml for release $NEW_VERSION"
git tag $NEW_VERSION
- name: Push back to GitHub
# Note we must push or otherwise next job won't have the commit (every job starts from scratch)
run: |
git push --all
git push origin $NEW_VERSION
build_jib_production:
name: "Build docker image via jib with tags: production,<VERSION>"
# note we must explicitly declare extract as a dep to use its outputs
needs:
- update-version-commit
- extract
runs-on:
- self-hosted
- java
# NOTE: by default checkout will get the revision at workflow trigger time. Here we want the latest (including commits from previous jobs), that's why we need the fetch-depth and pull
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Pull latest changes
run: |
git pull origin ${{ github.ref_name }}
- name: Jib build and push production image
run: |
echo "Jib build and push with tags production,${{ needs.extract.outputs.major }}.${{ needs.extract.outputs.minor }}.${{ needs.extract.outputs.patch }}"
mvn package jib:build -Djib.to.tags=production,${{ needs.extract.outputs.major }}.${{ needs.extract.outputs.minor }}.${{ needs.extract.outputs.patch }} -Djib.target.namespace=rcsb --no-transfer-progress -Dmaven.test.skip=true -Djib.httpTimeout=0
next-dev-cycle-commit:
# note we must explicitly declare extract as a dep to use its outputs
needs:
- build_jib_production
- extract
env:
NEW_VERSION: ${{ needs.extract.outputs.major }}.${{ needs.extract.outputs.minor }}.${{ needs.extract.outputs.patch }}
runs-on:
- self-hosted
- java
steps:
# NOTE: by default checkout will get the revision at workflow trigger time. Here we want the latest (including commits from previous jobs), that's why we need the fetch-depth and pull
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Pull latest changes
run: |
git pull origin ${{ github.ref_name }}
- name: Setup git author information
run: |
git config user.name RCSBSystem
git config user.email it@rcsb.org
- name: Increment version
run: |
NEXT_PATCH=$(mvn build-helper:parse-version help:evaluate -Dexpression=parsedVersion.nextIncrementalVersion -q -DforceStdout --no-transfer-progress)
mvn versions:set -DnewVersion="${{ needs.extract.outputs.major }}.${{ needs.extract.outputs.minor }}.$NEXT_PATCH-SNAPSHOT" -DallowSnapshots --no-transfer-progress
- name: Commit new version for next dev cycle
run: |
git add $(find . -name "pom.xml")
git commit -m "[actions] Next development cycle"
- name: Push back to GitHub
run: |
git push --all
git push origin $NEW_VERSION