-
Notifications
You must be signed in to change notification settings - Fork 10
151 lines (135 loc) · 6.2 KB
/
command-release.yml
File metadata and controls
151 lines (135 loc) · 6.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Command Release
on:
repository_dispatch:
types: [release-command]
permissions:
pull-requests: write
checks: write
id-token: write
contents: write
jobs:
meta:
needs: []
runs-on: windows-latest
outputs:
project: ${{ steps.meta.outputs.project }}
package: ${{ steps.meta.outputs.package }}
directory: ${{ steps.meta.outputs.directory }}
releaseNamePrefix: ${{ steps.meta.outputs.releaseNamePrefix }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.pull_request.head.ref }}
- id: meta
shell: pwsh
run: |
$directory = "${{ github.event.client_payload.slash_command.args.unnamed.arg1 }}"
$package = "${{ github.event.client_payload.slash_command.args.unnamed.arg2 }}"
Write-Output "package=$package"
Write-Output "package=$package" >> $env:GITHUB_OUTPUT
Write-Output "directory=$directory/src"
Write-Output "directory=$directory/src" >> $env:GITHUB_OUTPUT
$prefix = ""
if($directory -eq "queue") {
$prefix = "fiskaltrust.Middleware.Queue"
Write-Output "releaseNamePrefix=Queue"
Write-Output "releaseNamePrefix=Queue" >> $env:GITHUB_OUTPUT
} elseif($directory -match "scu-([a-z]{2})") {
$prefix = "fiskaltrust.Middleware.SCU.$($matches[1].ToUpper())"
Write-Output "releaseNamePrefix=SCU.$($matches[1].ToUpper())"
Write-Output "releaseNamePrefix=SCU.$($matches[1].ToUpper())" >> $env:GITHUB_OUTPUT
}
$project = $(Get-Item "$directory/src/$prefix.$package").Name
Write-Output "project=$project"
Write-Output "project=$project" >> $env:GITHUB_OUTPUT
release:
runs-on: ubuntu-latest
needs: [meta]
outputs:
version: ${{ steps.create-release.outputs.version }}
tag: ${{ steps.create-release.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.client_payload.pull_request.head.ref }}
fetch-depth: 0
token: ${{ secrets.REPOSITORY_WRITE_PAT }}
- name: Install nbgv
run: dotnet tool update -g nbgv
- name: Configure git for PAT
run: |
git config user.name "ReleaseBot"
git config user.email "dev-portal-poscreator@fiskaltrust.de"
git remote set-url origin https://x-access-token:${{ secrets.REPOSITORY_WRITE_PAT }}@github.com/${{ github.repository }}.git
- name: Get Release Data
id: create-release
if: startsWith(github.event.client_payload.pull_request.head.ref, 'release/')
run: |
nbgv tag --project ${{ needs.meta.outputs.directory }}/${{ needs.meta.outputs.project }}
versionOutput=$(nbgv get-version --project ${{ needs.meta.outputs.directory }}/${{ needs.meta.outputs.project }} --public-release -f json)
version=$(echo "$versionOutput" | jq -r '.SemVer2')
tag=$(echo "$versionOutput" | jq -r ".VersionOptions.Release.TagName | sub(\"{version}\"; \"$version\")")
preRelease=$(echo "$versionOutput" | jq -r 'has("PrereleaseVersion") and .PrereleaseVersion != ""')
if ! git rev-parse "$tag" >/dev/null 2>&1; then
echo "Error: Tag $tag does not exist"
exit 1
fi
git push --tags
if [ "$preRelease" = "false" ]; then
releaseNotes="You can find the full release notes on our docs platform https://docs.fiskaltrust.cloud/changelog/middleware/$version."
else
releaseNotes="This is a prerelease for the next middleware version."
fi
echo "tag=$tag"
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "version=$version"
echo "version=$version" >> $GITHUB_OUTPUT
echo "preRelease=$preRelease"
echo "preRelease=$preRelease" >> $GITHUB_OUTPUT
echo "releaseNotes=$releaseNotes"
echo "releaseNotes=$releaseNotes" >> $GITHUB_OUTPUT
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.create-release.outputs.tag }}
name: "${{ needs.meta.outputs.releaseNamePrefix }}.${{ needs.meta.outputs.package }} v${{ steps.create-release.outputs.version }}"
body: "${{ steps.create-release.outputs.releaseNotes }}"
prerelease: ${{ steps.create-release.outputs.preRelease }}
generate_release_notes: false
make_latest: ${{ steps.create-release.outputs.preRelease == 'false'}}
env:
GITHUB_TOKEN: ${{ secrets.REPOSITORY_WRITE_PAT }}
success:
needs:
- release
runs-on: ubuntu-latest
if: success('release')
steps:
- name: Add reaction
uses: peter-evans/create-or-update-comment@v4
with:
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reactions: hooray
reactions-edit-mode: replace
edit-mode: replace
body: |
/${{ github.event.client_payload.slash_command.command }} ${{ github.event.client_payload.slash_command.args.all }}
[](${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ needs.release.outputs.tag }})
failure:
needs:
- release
runs-on: ubuntu-latest
if: failure()
steps:
- name: Add reaction
uses: peter-evans/create-or-update-comment@v4
with:
repository: ${{ github.event.client_payload.github.payload.repository.full_name }}
comment-id: ${{ github.event.client_payload.github.payload.comment.id }}
reactions: confused
reactions-edit-mode: replace
edit-mode: replace
body: |
/${{ github.event.client_payload.slash_command.command }} ${{ github.event.client_payload.slash_command.args.all }}
[](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})