Skip to content

Commit 4719dcb

Browse files
committed
Borrow the release process from pseudo-service
1 parent 86ef62c commit 4719dcb

File tree

9 files changed

+301
-37
lines changed

9 files changed

+301
-37
lines changed

.github/labels.yml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
# Labels names are important as they are used by Release Drafter to decide
3+
# regarding where to record them in changelog or if to skip them.
4+
#
5+
# The repository labels will be automatically configured using this file and
6+
# the GitHub Action https://github.com/marketplace/actions/github-labeler.
7+
- name: breaking
8+
description: Breaking Changes
9+
color: bfd4f2
10+
- name: bug
11+
description: Something isn't working
12+
color: d73a4a
13+
- name: build
14+
description: Build System and Dependencies
15+
color: bfdadc
16+
- name: ci
17+
description: Continuous Integration
18+
color: 4a97d6
19+
- name: dependencies
20+
description: Pull requests that update a dependency file
21+
color: 0366d6
22+
- name: documentation
23+
description: Improvements or additions to documentation
24+
color: 0075ca
25+
- name: duplicate
26+
description: This issue or pull request already exists
27+
color: cfd3d7
28+
- name: enhancement
29+
description: New feature or request
30+
color: a2eeef
31+
- name: github_actions
32+
description: Pull requests that update Github_actions code
33+
color: "000000"
34+
- name: good first issue
35+
description: Good for newcomers
36+
color: 7057ff
37+
- name: help wanted
38+
description: Extra attention is needed
39+
color: "008672"
40+
- name: invalid
41+
description: This doesn't seem right
42+
color: e4e669
43+
- name: performance
44+
description: Performance
45+
color: "016175"
46+
- name: question
47+
description: Further information is requested
48+
color: d876e3
49+
- name: refactoring
50+
description: Refactoring
51+
color: ef67c4
52+
- name: removal
53+
description: Removals and Deprecations
54+
color: 9ae7ea
55+
- name: style
56+
description: Style
57+
color: c120e5
58+
- name: testing
59+
description: Testing
60+
color: b1fc6f
61+
- name: wontfix
62+
description: This will not be worked on
63+
color: ffffff

.github/release-drafter.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
categories:
2+
- title: ":boom: Breaking Changes"
3+
label: "breaking"
4+
- title: ":rocket: Features"
5+
label: "enhancement"
6+
- title: ":fire: Removals and Deprecations"
7+
label: "removal"
8+
- title: ":beetle: Fixes"
9+
label: "bug"
10+
- title: ":racehorse: Performance"
11+
label: "performance"
12+
- title: ":rotating_light: Testing"
13+
label: "testing"
14+
- title: ":construction_worker: Continuous Integration"
15+
label: "ci"
16+
- title: ":books: Documentation"
17+
label: "documentation"
18+
- title: ":hammer: Refactoring"
19+
label: "refactoring"
20+
- title: ":lipstick: Style"
21+
label: "style"
22+
- title: ":package: Dependencies"
23+
labels:
24+
- "dependencies"
25+
- "build"
26+
27+
autolabeler:
28+
- label: 'documentation'
29+
branch:
30+
- '/docs{0,1}\/.+/'
31+
- label: 'bug'
32+
branch:
33+
- '/fix\/.+/'
34+
title:
35+
- '/fix/i'
36+
- label: 'enhancement'
37+
branch:
38+
- '/feat\/.+/'
39+
body:
40+
- '/JIRA-[0-9]{1,4}/'
41+
- label: 'refactoring'
42+
branch:
43+
- '/refactor\/.+/'
44+
title:
45+
- '/^refactor/i'
46+
- label: 'testing'
47+
branch:
48+
- '/test\/.+/'
49+
- label: 'breaking'
50+
title:
51+
- '/breaking change/i'
52+
- label: 'ci'
53+
files:
54+
- '.github/*'
55+
56+
template: |
57+
## Changes
58+
59+
$CHANGES

.github/workflows/labeler.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: Labeler
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
8+
jobs:
9+
labeler:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Check out the repository
13+
uses: actions/checkout@v4
14+
15+
# Reads labels from .github/labels.yml
16+
- name: Run Labeler
17+
uses: crazy-max/ghaction-github-labeler@v5
18+
with:
19+
skip-delete: true

.github/workflows/mvn-release.yml

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- release
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
# Do not run workflow if the triggering commit created the 'release' branch
12+
if: ${{github.event.created}} == false
13+
permissions:
14+
contents: write
15+
id-token: write
16+
packages: write
17+
18+
steps:
19+
- name: Create DaplaBot app token
20+
uses: actions/create-github-app-token@v1
21+
id: app-token
22+
with:
23+
app-id: ${{ secrets.DAPLA_BOT_APP_ID }}
24+
private-key: ${{ secrets.DAPLA_BOT_PRIVATE_KEY }}
25+
26+
- uses: actions/checkout@v4
27+
with:
28+
token: ${{ steps.app-token.outputs.token }}
29+
ref: refs/heads/master
30+
31+
- name: Set up JDK
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: 17
35+
distribution: temurin
36+
cache: maven
37+
overwrite-settings: false
38+
39+
- name: Get bot variables
40+
id: get-bot-vars
41+
run: |
42+
bot_name="dapla-bot"
43+
bot_id=$(curl -s https://api.github.com/users/${bot_name}%5Bbot%5D | jq '.id')
44+
bot_email="${dapla_bot_id}+${bot_name}[bot]@users.noreply.github.com"
45+
46+
echo "bot_name=${bot_name}[bot]" >> $GITHUB_OUTPUT
47+
echo "bot_email=${bot_email}" >> $GITHUB_OUTPUT
48+
49+
- name: Configure Git user
50+
run: |
51+
git config user.email ${{steps.get-bot-vars.outputs.bot_email}}
52+
git config user.name ${{steps.get-bot-vars.outputs.bot_name}}
53+
54+
- name: Setup Maven authentication to GitHub packages
55+
uses: s4u/maven-settings-action@v3.0.0
56+
with:
57+
override: true
58+
githubServer: false
59+
servers: >-
60+
[{"id": "github","username": "${{steps.get-bot-vars.outputs.bot_email}}","password": "${{steps.app-token.outputs.token}}",
61+
"configuration": {"httpHeaders": {"property": {"name": "Authorization","value": "Bearer ${{ secrets.GITHUB_TOKEN }}"}}}}]
62+
63+
- name: Maven release and deploy to GitHub packages
64+
id: release-artifact
65+
run: |
66+
# Get the release version from the pom.xml before the next snapshot increment
67+
VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout | sed "s/-SNAPSHOT//")
68+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
69+
# Perform the release/deploy and increment the version to the next snapshot
70+
mvn --batch-mode release:prepare -P github -Darguments="-Dmaven.test.skip=true -Dmaven.deploy.skip=true"
71+
mvn --batch-mode release:perform
72+
TAG=$(git describe --abbrev=0 --tags)
73+
echo "tag=${TAG}" >> $GITHUB_OUTPUT
74+
75+
- name: Create GitHub release draft
76+
uses: release-drafter/release-drafter@v6
77+
id: create-github-release
78+
env:
79+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
80+
with:
81+
tag: ${{ steps.release-artifact.outputs.tag }}
82+
83+
- name: Upload assets to GitHub release draft
84+
env:
85+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
86+
run: |
87+
ARTIFACT_ID=$(mvn help:evaluate -Dexpression=project.artifactId -q -DforceStdout)
88+
# Get all files matching the artifact id and version (source, javadoc, etc.)
89+
ARTIFACT_GLOB=(./target/$ARTIFACT_ID-${{ steps.release-artifact.outputs.version }}*.jar)
90+
for file in "${ARTIFACT_GLOB[@]}"; do
91+
echo "Uploading $file"
92+
gh release upload ${{ steps.create-github-release.outputs.tag_name }} $file
93+
done
94+
95+
- name: Publish GitHub release
96+
uses: eregon/publish-release@v1
97+
env:
98+
GITHUB_TOKEN: ${{ steps.app-token.outputs.token }}
99+
with:
100+
release_id: ${{ steps.create-github-release.outputs.id }}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release Drafter
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
# pull_request event is required only for autolabeler
8+
pull_request:
9+
types:
10+
- opened
11+
- reopened
12+
- synchronize
13+
14+
permissions:
15+
contents: read
16+
17+
jobs:
18+
update_release_draft:
19+
permissions:
20+
# write permission is required to create a GitHub release
21+
contents: write
22+
# write permission is required for autolabeler
23+
# otherwise, read permission is required at least
24+
pull-requests: write
25+
runs-on: ubuntu-latest
26+
steps:
27+
# Draft the next Release notes as Pull Requests are merged into main
28+
29+
- uses: release-drafter/release-drafter@v5
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

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

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ default: | help
2222
help:
2323
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
2424

25+
26+
.PHONY: release
27+
release:
28+
@set -e ; \
29+
git checkout master && \
30+
git pull && \
31+
git checkout release && \
32+
git merge master && \
33+
git push
34+
2535
.PHONY: build-klass-forvaltning
2636
build-klass-forvaltning:
2737
pushd klass-forvaltning && \

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ Run `mvn install` to build the project.
2626

2727
Klass is hosted on the Nais application platform. Deploy configuration may be found in the [.nais](.nais) directory. Deploy workflows may be found in the [.github/workflows](.github/workflows) directory.
2828

29+
## Release
30+
31+
The release process is automated. It can be triggered by following these steps:
32+
33+
1. Check that you are on the default branch.
34+
1. Check that you don't have any local commits or changes.
35+
1. Run `make release`. This command creates a branch called `release` and triggers the further release process like so:
36+
1. The version number is bumped for a minor release.
37+
2. The artifacts are deployed
38+
3. A tag is pushed
39+
4. The project is reset for the next development iteration
40+
5. A GitHub release is created which triggers deploy to the prod environment
41+
42+
This command pushes the current state of origin/master as well as locally committed changes to the release branch. This starts a workflow that performs a minor version bump, a GitHub release, and a deployment to the NAIS production environment.
43+
2944
## Database
3045

3146
Klass uses PostgreSQL for its database.

pom.xml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<groupId>no.ssb.klass</groupId>
@@ -11,7 +12,7 @@
1112
<groupId>org.springframework.boot</groupId>
1213
<artifactId>spring-boot-starter-parent</artifactId>
1314
<version>3.5.10</version>
14-
<relativePath />
15+
<relativePath/>
1516
</parent>
1617

1718
<modules>
@@ -24,7 +25,6 @@
2425
<scm>
2526
<developerConnection>scm:git:https://github.com/${github.repository}.git</developerConnection>
2627
<url>https://github.com/${github.repository}</url>
27-
<tag>v4.0.0</tag>
2828
</scm>
2929

3030
<properties>
@@ -65,7 +65,7 @@
6565
<name>GitHub Packages</name>
6666
<url>https://maven.pkg.github.com/${github.repository}</url>
6767
<snapshots>
68-
<enabled>true</enabled>
68+
<enabled>false</enabled>
6969
</snapshots>
7070
</repository>
7171
</distributionManagement>
@@ -106,11 +106,6 @@
106106
<arguments>-Pdocumentation -Dmaven.javadoc.skip=true -pl :klass-api -am</arguments>
107107
</configuration>
108108
</plugin>
109-
<plugin>
110-
<groupId>org.apache.maven.plugins</groupId>
111-
<artifactId>maven-deploy-plugin</artifactId>
112-
<version>3.1.4</version>
113-
</plugin>
114109
<plugin>
115110
<groupId>org.springframework.boot</groupId>
116111
<artifactId>spring-boot-maven-plugin</artifactId>

0 commit comments

Comments
 (0)