Skip to content

Commit 377fdc6

Browse files
authored
chore: prepare for release of v0.0.5 (#33)
* update version to 0.0.5 * add script for release maintenance * simplify release workflow * workflow to create tag on PR merge
1 parent c4fc8ce commit 377fdc6

File tree

6 files changed

+101
-55
lines changed

6 files changed

+101
-55
lines changed

.github/workflows/release-workflow.yml

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,9 @@ jobs:
1818

1919
prepare-release:
2020
needs: extract-version
21-
22-
name: "tagged release"
2321
runs-on: ubuntu-latest
2422

25-
outputs:
26-
updated-sha: ${{ steps.get-latest-sha.outputs.updated-sha }}
27-
2823
steps:
29-
- name: "display tag name"
30-
run: |
31-
echo "found tag name ${{ needs.extract-version.outputs.clean_version }}"
32-
3324
- name: checkout sources
3425
uses: actions/checkout@v4
3526

@@ -39,50 +30,11 @@ jobs:
3930
java-version: '21'
4031
distribution: 'temurin'
4132

42-
- name: "update version to tag"
43-
run: |
44-
mvn versions:set -DnewVersion=${{ needs.extract-version.outputs.clean_version }} -DprocessAllModules
45-
mvn versions:update-properties -DincludeProperties=ssh-signer-common-lib.version
46-
mvn versions:commit
47-
48-
- name: commit new version
49-
id: get-latest-sha
50-
run: |
51-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
52-
git config --global user.name "GitHub Actions"
53-
54-
# create a temporary branch from the tag
55-
git switch -c temp-from-tag
56-
57-
git add .
58-
git commit -m "Update version to ${{ needs.extract-version.outputs.clean_version }}"
59-
60-
# force move the tag to the new commit
61-
git tag -f ${{ github.ref_name }}
62-
git push origin ${{ github.ref_name }} --force
63-
64-
# merge to main
65-
git fetch origin
66-
git switch main
67-
git merge temp-from-tag --no-ff -m "Merge tag ${{ github.ref_name }} changes into main"
68-
69-
git push origin main
70-
71-
# cleanup temp branch
72-
git branch -d temp-from-tag
73-
74-
NEW_SHA=$(git rev-parse main)
75-
echo "updated-sha=$NEW_SHA" >> $GITHUB_OUTPUT
76-
77-
- name: debug the SHA
78-
run: |
79-
echo "The SHA exported is: ${{ steps.get-latest-sha.outputs.updated-sha }}"
80-
8133
docker-build:
8234
needs: prepare-release
8335
uses: ./.github/workflows/ssh-key-signer-server-docker.yml
8436
with:
85-
sha: ${{ needs.prepare-release.outputs.updated-sha }}
37+
sha: ${{ github.sha }}
8638
secrets: inherit
8739

8840
go-build:
@@ -91,7 +43,7 @@ jobs:
9143
with:
9244
service: go-ssh-keysign
9345
artifactVersion: ${{ needs.extract-version.outputs.clean_version }}
94-
sha: ${{ needs.prepare-release.outputs.updated-sha }}
46+
sha: ${{ github.sha }}
9547

9648
create-release:
9749
needs: [docker-build, go-build]
@@ -102,7 +54,7 @@ jobs:
10254
id: create_release
10355
uses: actions/create-release@v1
10456
with:
105-
tag_name: ${{ github.ref }} # The tag that triggered the release
57+
tag_name: ${{ github.ref }}
10658
release_name: Release ${{ github.ref }}
10759
draft: true
10860
prerelease: true

.github/workflows/tag-on-merge.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: 'create tag on release prepare PR merge'
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
tagging:
11+
if: github.event.pull_request.merged == true
12+
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
17+
steps:
18+
- name: extract tag name from branch
19+
id: tag_extraction
20+
run: |
21+
# Get the head branch name of the PR (e.g., 'prepare-v0.0.5')
22+
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
23+
24+
# Check if the branch name starts with 'prepare-v'
25+
if [[ $BRANCH_NAME =~ ^prepare-v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
26+
# Extract the version part (e.g., 'v0.0.5') by removing 'prepare-'
27+
VERSION_TAG=$(echo "$BRANCH_NAME" | sed 's/^prepare-//')
28+
echo "::set-output name=version_tag::$VERSION_TAG"
29+
echo "Extracted tag: $VERSION_TAG"
30+
else
31+
echo "Branch name $BRANCH_NAME does not match the 'prepare-vX.Y.Z' convention. Skipping tag creation."
32+
# Set an empty output to skip the next steps
33+
echo "::set-output name=version_tag::"
34+
fi
35+
36+
- name: create and push tag
37+
if: steps.tag_extraction.outputs.version_tag != ''
38+
uses: actions/github-script@v6
39+
with:
40+
script: |
41+
const tag = steps.tag_extraction.outputs.version_tag;
42+
43+
console.log(`Creating tag ${tag}`);
44+
45+
// Create the tag using the GitHub API
46+
await github.rest.git.createRef({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
ref: `refs/tags/${tag}`,
50+
sha: context.sha
51+
});
52+
53+
console.log(`Successfully created tag ${tag}`);

server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<groupId>io.binarycodes.homelab</groupId>
88
<artifactId>ssh-signer-mono</artifactId>
99
<name>SSH KeySigner</name>
10-
<version>0.0.4</version>
10+
<version>0.0.5</version>
1111

1212
<packaging>pom</packaging>
1313

server/ssh-key-signer-server/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>io.binarycodes.homelab</groupId>
77
<artifactId>ssh-key-signer-server</artifactId>
8-
<version>0.0.4</version>
8+
<version>0.0.5</version>
99
<packaging>jar</packaging>
1010

1111
<name>Server - SSH Key Signer</name>
@@ -14,7 +14,7 @@
1414
<properties>
1515
<java.version>21</java.version>
1616
<vaadin.version>24.9.2</vaadin.version>
17-
<ssh-signer-common-lib.version>0.0.4</ssh-signer-common-lib.version>
17+
<ssh-signer-common-lib.version>0.0.5</ssh-signer-common-lib.version>
1818
</properties>
1919

2020
<parent>

server/ssh-signer-common-lib/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.binarycodes.homelab</groupId>
88
<artifactId>ssh-signer-common-lib</artifactId>
9-
<version>0.0.4</version>
9+
<version>0.0.5</version>
1010

1111
<name>Common Library - SSH Key Signer</name>
1212

update_app_version.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
set -eu -o pipefail
4+
5+
EXIT_IF_DIRTY=false
6+
7+
if [ -n "$(git status --porcelain -uall)" ]; then
8+
echo "Working directory is dirty (tracked changes OR untracked files)."
9+
$EXIT_IF_DIRTY && exit 1
10+
fi
11+
12+
cd ./server
13+
14+
current_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)
15+
16+
read -p "Current version is [$current_version] Please enter the next version : " version
17+
18+
branch_name="prepare-v${version}"
19+
git switch -c ${branch_name}
20+
21+
mvn versions:set -DnewVersion=${version} -DprocessAllModules
22+
mvn versions:update-properties -DincludeProperties=ssh-signer-common-lib.version
23+
mvn versions:commit
24+
25+
git add .
26+
git commit -S -m "update version to $version"
27+
git push --set-upstream origin ${branch_name}
28+
29+
gh auth status -h github.com -a > /dev/null 2>&1
30+
if [ $? -eq 0 ]; then
31+
echo "GitHub CLI is logged in. Proceeding..."
32+
else
33+
echo "GitHub CLI is NOT logged in. Running gh auth login..."
34+
gh auth login -h github.com -p ssh --skip-ssh-key -w
35+
fi
36+
37+
gh pr create \
38+
--base main \
39+
--head ${branch_name} \
40+
--title "chore: prepare for release of v${version}" \
41+
--body "This PR is in preparationg for release of version ${version}." \

0 commit comments

Comments
 (0)