Skip to content

Commit 506a103

Browse files
committed
feat: add reusable release workflow and use it to also release BOM
1 parent 6657549 commit 506a103

File tree

2 files changed

+103
-93
lines changed

2 files changed

+103
-93
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Release project in specified directory
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
project-dir:
7+
type: string
8+
required: true
9+
version-branch:
10+
type: string
11+
required: true
12+
13+
jobs:
14+
publish:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout "${{inputs.version-branch}}" branch
18+
uses: actions/checkout@v3
19+
with:
20+
ref: "${{inputs.version-branch}}"
21+
22+
- name: Set up Java and Maven
23+
uses: actions/setup-java@v3
24+
with:
25+
java-version: 11
26+
distribution: temurin
27+
cache: 'maven'
28+
29+
- name: Move to specified directory
30+
working-directory: ${{inputs.project-dir}}
31+
run: |
32+
echo "Releasing from ${{inputs.project-dir}}"
33+
shell: bash
34+
35+
- name: Change version to release version
36+
# Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
37+
run: mvn ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
38+
env:
39+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
40+
41+
- name: Release Maven package
42+
uses: samuelmeuli/action-maven-publish@v1
43+
with:
44+
maven_profiles: "release"
45+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
46+
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
47+
nexus_username: ${{ secrets.OSSRH_USERNAME }}
48+
nexus_password: ${{ secrets.OSSRH_TOKEN }}
49+
50+
# This is separate job because there were issues with git after release step, was not able to commit changes.
51+
update-working-version:
52+
runs-on: ubuntu-latest
53+
if: "success() && !contains(github.event.release.tag_name, 'RC')" # not sure we should keep this the RC part
54+
steps:
55+
- uses: actions/checkout@v3
56+
with:
57+
ref: "${{inputs.version-branch}}"
58+
59+
- name: Set up Java and Maven
60+
uses: actions/setup-java@v3
61+
with:
62+
java-version: 11
63+
distribution: temurin
64+
cache: 'maven'
65+
66+
- name: Change version to release version
67+
run: |
68+
mvn ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
69+
mvn ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit
70+
git config --local user.email "[email protected]"
71+
git config --local user.name "GitHub Action"
72+
git commit -m "Set new SNAPSHOT version into pom files." -a
73+
env:
74+
RELEASE_VERSION: ${{ github.event.release.tag_name }}
75+
76+
- name: Push changes to branch
77+
uses: ad-m/github-push-action@master
78+
with:
79+
branch: "${{inputs.version-branch}}"
80+
github_token: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

+23-93
Original file line numberDiff line numberDiff line change
@@ -8,101 +8,31 @@ jobs:
88
publish:
99
runs-on: ubuntu-latest
1010
steps:
11-
- uses: actions/checkout@v3
12-
if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }}
13-
with:
14-
ref: "v1"
15-
- uses: actions/checkout@v3
16-
if: ${{ startsWith(github.event.release.tag_name, 'v2.') }}
17-
with:
18-
ref: "v2"
19-
- uses: actions/checkout@v3
20-
if: ${{ startsWith(github.event.release.tag_name, 'v3.') }}
21-
with:
22-
ref: "v3"
23-
- uses: actions/checkout@v3
24-
if: ${{ startsWith(github.event.release.tag_name, 'v4.') }}
25-
- name: Set up Java and Maven
26-
uses: actions/setup-java@v3
27-
with:
28-
java-version: 11
29-
distribution: temurin
30-
cache: 'maven'
31-
- name: change version to release version
32-
# Assume that RELEASE_VERSION will have form like: "v1.0.1". So we cut the "v"
33-
run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
11+
- if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }}
3412
env:
35-
RELEASE_VERSION: ${{ github.event.release.tag_name }}
36-
- name: change version to release version for bom module
37-
working-directory: ./operator-framework-bom
38-
run: ./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
13+
version-branch: "v1"
14+
- if: ${{ startsWith(github.event.release.tag_name, 'v2.' ) }}
3915
env:
40-
RELEASE_VERSION: ${{ github.event.release.tag_name }}
41-
- name: Release Maven package
42-
uses: samuelmeuli/action-maven-publish@v1
43-
with:
44-
maven_profiles: "release"
45-
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
46-
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
47-
nexus_username: ${{ secrets.OSSRH_USERNAME }}
48-
nexus_password: ${{ secrets.OSSRH_TOKEN }}
49-
50-
51-
# This is separate job because there were issues with git after release step, was not able to commit changes. See history.
52-
update-working-version:
53-
runs-on: ubuntu-latest
54-
if: "!contains(github.event.release.tag_name, 'RC')"
55-
steps:
56-
- uses: actions/checkout@v3
57-
if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }}
58-
with:
59-
ref: "v1"
60-
- uses: actions/checkout@v3
61-
if: ${{ startsWith(github.event.release.tag_name, 'v2.') }}
62-
with:
63-
ref: "v2"
64-
- uses: actions/checkout@v3
65-
if: ${{ startsWith(github.event.release.tag_name, 'v3.') }}
66-
with:
67-
ref: "v3"
68-
- uses: actions/checkout@v3
69-
if: ${{ startsWith(github.event.release.tag_name, 'v4.') }}
70-
- name: Set up Java and Maven
71-
uses: actions/setup-java@v3
72-
with:
73-
java-version: 11
74-
distribution: temurin
75-
cache: 'maven'
76-
- name: change version to release version
77-
run: |
78-
./mvnw ${MAVEN_ARGS} versions:set -DnewVersion="${RELEASE_VERSION:1}" versions:commit
79-
./mvnw ${MAVEN_ARGS} -q build-helper:parse-version versions:set -DnewVersion=\${parsedVersion.majorVersion}.\${parsedVersion.minorVersion}.\${parsedVersion.nextIncrementalVersion}-SNAPSHOT versions:commit
80-
git config --local user.email "[email protected]"
81-
git config --local user.name "GitHub Action"
82-
git commit -m "Set new SNAPSHOT version into pom files." -a
16+
version-branch: "v2"
17+
- if: ${{ startsWith(github.event.release.tag_name, 'v3.' ) }}
8318
env:
84-
RELEASE_VERSION: ${{ github.event.release.tag_name }}
85-
- name: Push changes v1
86-
uses: ad-m/github-push-action@master
87-
if: ${{ startsWith(github.event.release.tag_name, 'v1.' ) }}
88-
with:
89-
github_token: ${{ secrets.GITHUB_TOKEN }}
90-
branch: "v1"
91-
- name: Push changes v2
92-
uses: ad-m/github-push-action@master
93-
if: ${{ startsWith(github.event.release.tag_name, 'v2.' ) }}
94-
with:
95-
github_token: ${{ secrets.GITHUB_TOKEN }}
96-
branch: "v2"
97-
- name: Push changes v3
98-
uses: ad-m/github-push-action@master
99-
if: ${{ startsWith(github.event.release.tag_name, 'v3.' ) }}
100-
with:
101-
github_token: ${{ secrets.GITHUB_TOKEN }}
102-
branch: "v3"
103-
- name: Push changes v4
104-
uses: ad-m/github-push-action@master
105-
if: ${{ startsWith(github.event.release.tag_name, 'v4.' ) }}
19+
version-branch: "v3"
20+
- if: ${{ startsWith(github.event.release.tag_name, 'v4.' ) }}
21+
env:
22+
version-branch: "main"
23+
- name: Fail if version-branch is not set
24+
if: "version-branch == ''"
25+
run: exit 1
26+
27+
- name: Release SDK
28+
uses: ./.github/workflows/release-project-in-dir.yml
10629
with:
107-
github_token: ${{ secrets.GITHUB_TOKEN }}
30+
version-branch: ${{version-branch}}
31+
project-dir: '.'
10832

33+
- name: Release BOM
34+
uses: ./.github/workflows/release-project-in-dir.yml
35+
with:
36+
version-branch: ${{version-branch}}
37+
project-dir: './operator-framework-bom'
38+

0 commit comments

Comments
 (0)