Skip to content

Commit 376b71d

Browse files
authored
Use jreleaser, remove release-drafter. (#279)
* feat: use jreleaser for assembling and publishing the release * Fix owner * Make version fragment a choice input.
1 parent 631ad42 commit 376b71d

File tree

8 files changed

+148
-97
lines changed

8 files changed

+148
-97
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: 'Increase semantic version'
2+
description: 'Increases '
3+
inputs:
4+
current-version:
5+
description: 'The current semantic version string'
6+
required: true
7+
version-fragment:
8+
description: 'The version fragment to increase'
9+
required: false
10+
default: 'minor'
11+
outputs:
12+
next-version:
13+
description: "The next semantic version string with the specific fragment being increased"
14+
value: ${{ steps.increase-semver.outputs.next-version }}
15+
runs:
16+
using: "composite"
17+
steps:
18+
- uses: actions/setup-python@b64ffcaf5b410884ad320a9cfac8866006a109aa # v4.8.0
19+
with:
20+
python-version: '3.10'
21+
cache: 'pip'
22+
- shell: bash
23+
run: pip install -r $GITHUB_ACTION_PATH/requirements.txt
24+
- id: increase-semver
25+
shell: bash
26+
run: |
27+
NEXT_VERSION=$(cd $GITHUB_ACTION_PATH && python increase_semver.py ${{ inputs.current-version }} ${{ inputs.version-fragment }})
28+
echo "Next Version: $NEXT_VERSION"
29+
echo "next-version=${NEXT_VERSION}" >> $GITHUB_OUTPUT
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# *******************************************************************************
2+
# Copyright (c) 2023 Eclipse Foundation and others.
3+
# This program and the accompanying materials are made available
4+
# under the terms of the MIT License
5+
# which is available at https://spdx.org/licenses/MIT.html
6+
# SPDX-License-Identifier: MIT
7+
# *******************************************************************************
8+
9+
import sys
10+
from semver.version import Version
11+
12+
13+
def run(current_version: str, version_fragment: str) -> None:
14+
v = Version.parse(current_version)
15+
print(str(v.next_version(part=version_fragment)))
16+
17+
18+
if __name__ == "__main__":
19+
args = sys.argv[1:]
20+
21+
if len(args) != 2:
22+
print("Error: Need to provide 2 arguments: 'current-version' and 'version-fragment'.")
23+
exit(1)
24+
25+
run(args[0], args[1])
26+
exit(0)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
semver==3.0.2

.github/release-drafter.yml

Lines changed: 0 additions & 1 deletion
This file was deleted.

.github/workflows/release-drafter.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/release.yml

Lines changed: 90 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,47 @@
11
name: Release
22
on:
33
workflow_dispatch:
4+
inputs:
5+
version:
6+
description: 'Release version'
7+
required: true
8+
version-fragment:
9+
description: 'Version fragment to increase for next development cycle'
10+
required: true
11+
default: 'minor'
12+
type: choice
13+
options:
14+
- major
15+
- minor
16+
- patch
417

518
env:
619
BOT_USER_NAME: eclipse-cbi-bot
720
BOT_EMAIL: cbi-bot@eclipse.org
8-
JAVA_VERSION: '17'
21+
JAVA_VERSION: 17
922
JAVA_DISTRO: 'temurin'
1023

1124
concurrency:
1225
group: ${{ github.workflow }}-${{ github.ref }}
13-
cancel-in-progress: true
14-
15-
permissions: # added using https://github.com/step-security/secure-repo
16-
contents: read
26+
cancel-in-progress: false
1727

1828
jobs:
19-
build:
20-
runs-on: ubuntu-latest
21-
# don't run this workflow in forks
22-
if: github.repository == 'eclipse-cbi/macos-notarization-service'
29+
precheck:
30+
runs-on: ubuntu-22.04
2331
permissions:
2432
contents: write
33+
if: github.repository == 'eclipse-cbi/macos-notarization-service'
2534
outputs:
26-
tag: ${{ steps.retrieve-tag.outputs.tag }}
27-
hash: ${{ steps.hash.outputs.hash }}
35+
release-version: ${{ steps.prepare-release.outputs.RELEASE_VERSION }}
2836
steps:
37+
- name: Check ref
38+
shell: bash
39+
run: |
40+
if [ "${{ github.ref }}" != "refs/heads/main" ]; then
41+
echo "Release shall only be made from 'main' branch, triggered branch '${{ github.ref_name }}', aborting."
42+
exit 1
43+
fi
44+
2945
- name: Setup Git User
3046
run: |
3147
git config --global user.name '${{ env.BOT_USER_NAME }}'
@@ -34,6 +50,7 @@ jobs:
3450
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3551
with:
3652
ref: ${{ github.ref }}
53+
fetch-depth: 0
3754

3855
- name: Setup Java
3956
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
@@ -42,70 +59,77 @@ jobs:
4259
distribution: ${{ env.JAVA_DISTRO }}
4360
cache: maven
4461

45-
- name: Build Release
62+
- name: Prepare release
63+
id: prepare-release
64+
shell: bash
4665
run: |
47-
./mvnw -ntp -B -Prelease release:clean release:prepare -Dmaven.test.skip=true
48-
./mvnw -ntp -B -Pdist -Prelease -Psbom release:perform -Darguments="-Dmaven.deploy.skip=true" -Dgoals=package
49-
env:
50-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
66+
PROJECT_VERSION="$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)"
67+
RELEASE_VERSION="${{ github.event.inputs.version }}"
5168
52-
- id: retrieve-tag
53-
run: |
54-
echo "tag=$(git describe --tags --abbrev=0)" >> "$GITHUB_OUTPUT"
55-
56-
- if: cancelled() || failure()
57-
run: ./mvnw -B -Prelease release:rollback
58-
env:
59-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
echo "PROJECT_VERSION=$(echo $PROJECT_VERSION)" >> $GITHUB_OUTPUT
70+
echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_OUTPUT
71+
72+
echo "Project version: $PROJECT_VERSION"
73+
echo "Release version: $RELEASE_VERSION"
74+
75+
if git show-ref --tags --verify --quiet "refs/tags/v${RELEASE_VERSION}"; then
76+
echo "Release Tag 'v${RELEASE_VERSION}' already exists, aborting."
77+
exit 1
78+
fi
79+
80+
if [ "$PROJECT_VERSION" != "$RELEASE_VERSION" ]; then
81+
./mvnw -B versions:set versions:commit -DnewVersion=$RELEASE_VERSION
82+
git commit -a -m "Releasing version $RELEASE_VERSION"
83+
git push origin ${{ github.ref }}
84+
fi
6085

61-
# Generate hashes used for provenance.
62-
- name: generate hash
63-
id: hash
64-
run: cd target/checkout/target/distributions && echo "hash=$(sha256sum * | base64 -w0)" >> $GITHUB_OUTPUT
65-
66-
- uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3.1.3
67-
with:
68-
path: target/checkout/target/distributions
69-
70-
71-
update_release_draft:
72-
needs: ['build']
86+
release:
87+
needs: ['precheck']
7388
permissions:
7489
contents: write
75-
pull-requests: read
76-
runs-on: ubuntu-latest
77-
steps:
78-
# Update the release notes for the released version
79-
- uses: release-drafter/release-drafter@09c613e259eb8d4e7c81c2cb00618eb5fc4575a7 # v5.25.0
80-
with:
81-
tag: ${{ needs.build.outputs.tag }}
82-
env:
83-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
84-
85-
provenance:
86-
needs: ['build']
87-
permissions:
8890
actions: read
91+
packages: write
8992
id-token: write
90-
contents: write
91-
# Can't pin with hash due to how this workflow works.
92-
uses: slsa-framework/slsa-github-generator/.github/workflows/generator_generic_slsa3.yml@v1.9.0
93+
uses: jreleaser/release-action/.github/workflows/builder_slsa3.yml@java
9394
with:
94-
base64-subjects: ${{ needs.build.outputs.hash }}
95+
project-version: ${{ needs.precheck.outputs.release-version }}
96+
branch: ${{ github.ref_name }}
97+
jreleaser-version: '1.9.0'
98+
java-version: 17
99+
java-distribution: 'temurin'
100+
rekor-log-public: true
101+
secrets:
102+
github-token: ${{ secrets.GITHUB_TOKEN }}
95103

96-
upload-artifacts:
97-
# Upload the distribution and provenance to a GitHub release. They remain
98-
# available as build artifacts for a while as well.
99-
needs: ['build', 'provenance', 'update_release_draft']
100-
runs-on: ubuntu-latest
104+
prepare-for-next-development-cycle:
105+
runs-on: ubuntu-22.04
106+
needs: ['precheck', 'release']
101107
permissions:
102108
contents: write
103109
steps:
104-
- uses: actions/download-artifact@9bc31d5ccc31df68ecc42ccf4149144866c47d8a # v3.0.2
105-
- name: upload artifacts to release
106-
run: >
107-
gh release upload --repo ${{ github.repository }}
108-
${{ needs.build.outputs.tag }}
109-
*.intoto.jsonl/* artifact/*
110-
env:
111-
GH_TOKEN: ${{ github.token }}
110+
- name: Setup Git User
111+
run: |
112+
git config --global user.name '${{ env.BOT_USER_NAME }}'
113+
git config --global user.email '${{ env.BOT_EMAIL }}'
114+
115+
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
116+
with:
117+
ref: ${{ github.ref }}
118+
119+
- name: Setup Java
120+
uses: actions/setup-java@0ab4596768b603586c0de567f2430c30f5b0d2b0 # v3.13.0
121+
with:
122+
java-version: ${{ env.JAVA_VERSION }}
123+
distribution: ${{ env.JAVA_DISTRO }}
124+
cache: maven
125+
126+
- id: increase-semver
127+
uses: ./.github/actions/increase-semver
128+
with:
129+
current-version: ${{ needs.precheck.outputs.release-version }}
130+
version-fragment: ${{ github.event.inputs.version-fragment }}
131+
- name: Update next development version in POMs
132+
run: |
133+
./mvnw -B versions:set versions:commit -DnewVersion=${{ steps.increase-semver.outputs.next-version }}-SNAPSHOT -DgenerateBackupPoms=false
134+
git commit -a -m "Prepare for next development cycle"
135+
git push origin ${{ github.ref }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.classpath
44
.settings/
55
bin/
6+
out/
67

78
# IntelliJ
89
.idea

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<properties>
88
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
99
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
10-
<project.build.outputTimestamp>1698421459</project.build.outputTimestamp>
10+
<project.build.outputTimestamp>1702162494</project.build.outputTimestamp>
1111
<maven.compiler.source>17</maven.compiler.source>
1212
<maven.compiler.target>17</maven.compiler.target>
1313
<maven.compiler.parameters>true</maven.compiler.parameters>

0 commit comments

Comments
 (0)