1
1
name : Publish Package to ghcr.io
2
2
3
3
on :
4
- release :
5
- types : [published ]
4
+ pull_request :
5
+ types : [closed ]
6
6
workflow_dispatch :
7
7
8
- env :
9
- REGISTRY : ghcr.io
10
- IMAGE_NAME : ${{ github.repository }}
11
-
12
8
jobs :
13
- build-and-push-image :
9
+ release_draft :
10
+ permissions :
11
+ contents : write
12
+ pull-requests : write
13
+ runs-on : ubuntu-latest
14
+ steps :
15
+ - uses : release-drafter/release-drafter@v5
16
+ env :
17
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
18
+
19
+ build :
14
20
runs-on : ubuntu-latest
15
21
16
22
permissions :
@@ -21,29 +27,56 @@ jobs:
21
27
22
28
environment : ghcr:leanix-github-agent
23
29
30
+ if : github.event.pull_request.merged
31
+
24
32
steps :
25
- - name : Extract Docker image tag
26
- id : extract_tag
27
- run : |
28
- TAG=${GITHUB_REF#refs/tags/}
29
- CLEAN_TAG=${TAG//[^0-9.]/}
30
- echo "Docker image tag: ${CLEAN_TAG}"
31
- echo "::set-output name=tag::${CLEAN_TAG}"
33
+ - name : Tag next version
34
+ id : tag-action
35
+ uses : K-Phoen/semver-release-action@master
36
+ with :
37
+ release_branch : main
38
+ release_strategy : tag
39
+ env :
40
+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
41
+
42
+ - name : Publish Release Draft
43
+ uses : actions/github-script@v6.4.1
44
+ if : (steps.tag-action.outputs.tag != '')
45
+ with :
46
+ github-token : ${{secrets.GITHUB_TOKEN}}
47
+ script : |
48
+ const tag = "${{ steps.tag-action.outputs.tag }}";
49
+ const { data: releases } = await github.rest.repos.listReleases({
50
+ owner: context.repo.owner,
51
+ repo: context.repo.repo
52
+ });
53
+ const draftRelease = releases.find(release => release.tag_name === tag && release.draft === true);
54
+ if (!draftRelease) {
55
+ console.log(`No draft release found for tag ${tag}`);
56
+ return;
57
+ }
58
+ await github.rest.repos.updateRelease({
59
+ owner: context.repo.owner,
60
+ repo: context.repo.repo,
61
+ release_id: draftRelease.id,
62
+ draft: false
63
+ });
64
+ console.log(`Published draft release for tag ${tag}`);
32
65
33
66
- name : Checkout
34
67
uses : actions/checkout@v3
35
- if : (steps.extract_tag .outputs.tag != '')
68
+ if : (steps.tag-action .outputs.tag != '')
36
69
37
70
- name : Setup Java
38
71
uses : actions/setup-java@v3
39
- if : (steps.extract_tag .outputs.tag != '')
72
+ if : (steps.tag-action .outputs.tag != '')
40
73
with :
41
74
distribution : ' temurin'
42
- java-version : ' 21 '
75
+ java-version : ' 17 '
43
76
44
77
- name : Build with Gradle
45
78
uses : gradle/gradle-build-action@v2
46
- if : (steps.extract_tag .outputs.tag != '')
79
+ if : (steps.tag-action .outputs.tag != '')
47
80
continue-on-error : false
48
81
with :
49
82
arguments : build
67
100
with :
68
101
context : .
69
102
push : true
70
- tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.extract_tag .outputs.tag }}
103
+ tags : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.tag-action .outputs.tag }}
71
104
labels : ${{ steps.meta.outputs.labels }}
72
105
73
106
- name : Generate artifact attestation
0 commit comments