-
Notifications
You must be signed in to change notification settings - Fork 0
181 lines (153 loc) · 5.79 KB
/
release.yml
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Release
on:
push:
branches: [ master ]
permissions:
contents: write
pull-requests: write
jobs:
check-code:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Build entirely in docker
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/build-push-action@v6
with:
context: ./src
push: false
tags: oidc-server-mock:experimental
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
prepare-release:
runs-on: ubuntu-latest
needs: [check-code]
outputs:
upload_url: ${{ steps.create-release.outputs.upload_url }}
version: ${{ steps.version.outputs.release }}
steps:
- uses: actions/checkout@v4
- name: Configure Git
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
- name: Un-SNAP
run: |
version=$(grep -oPm1 "(?<=<VersionPrefix>)[^<]+" <<< cat src/OpenIdConnectServerMock.csproj)
new_version=${version::-9}
sed -i "s/\(<VersionPrefix>\)[^<>]*\(<\/VersionPrefix.*\)/\1$new_version\2/" src/OpenIdConnectServerMock.csproj
- name: Get version
id: version
run: |
version=$(grep -oPm1 "(?<=<VersionPrefix>)[^<]+" <<< cat src/OpenIdConnectServerMock.csproj)
echo "release=$version" >> $GITHUB_OUTPUT
echo "releasenumber=${version//[!0-9]/}" >> $GITHUB_OUTPUT
- name: Commit and Push
run: |
git add -A
git commit -m "Release ${{ steps.version.outputs.release }}"
git push origin
git tag v${{ steps.version.outputs.release }}
git push origin --tags
- name: Create Release
id: create-release
uses: shogo82148/actions-create-release@v1
with:
tag_name: v${{ steps.version.outputs.release }}
release_name: v${{ steps.version.outputs.release }}
commitish: master
body: |
## [Changelog](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }})
See [Changelog#v${{ steps.version.outputs.release }}](https://github.com/${{ github.repository }}/blob/develop/CHANGELOG.md#${{ steps.version.outputs.releasenumber }}) for more information.
## Installation
### Docker
Download the image from
* [DockerHub](https://hub.docker.com/r/xdevsoftware/oidc-server-mock/tags?name=${{ steps.version.outputs.release }})
* [GitHub Packages (ghcr.io)](https://github.com/xdev-software/oidc-server-mock/pkgs/container/oidc-server-mock)
publish-docker:
runs-on: ubuntu-latest
needs: [prepare-release]
permissions:
packages: write
contents: read
attestations: write
id-token: write
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git pull
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to ghcr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKERHUB_USERNAME }}/oidc-server-mock
ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}},value=${{ needs.prepare-release.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=${{ needs.prepare-release.outputs.version }}
type=semver,pattern={{major}},value=${{ needs.prepare-release.outputs.version }}
latest
- uses: docker/build-push-action@v6
id: push
with:
context: ./src
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,compression=zstd,force-compression=true
- name: Generate artifact attestation (ghcr.io)
uses: actions/attest-build-provenance@v2
with:
subject-name: ghcr.io/${{ github.repository }}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
after-release:
runs-on: ubuntu-latest
needs: [publish-docker]
steps:
- uses: actions/checkout@v4
- name: Init Git and pull
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git pull
- name: Inc Version and SNAP
run: |
version=$(grep -oPm1 "(?<=<VersionPrefix>)[^<]+" <<< cat src/OpenIdConnectServerMock.csproj)
new_version="$(echo $version | awk -F. -v OFS=. 'NF==1{print ++$NF}; NF>1{if(length($NF+1)>length($NF))$(NF-1)++; $NF=sprintf("%0*d", length($NF), ($NF+1)%(10^length($NF))); print}')-SNAPSHOT"
sed -i "s/\(<VersionPrefix>\)[^<>]*\(<\/VersionPrefix.*\)/\1$new_version\2/" src/OpenIdConnectServerMock.csproj
- name: Git Commit and Push
run: |
git add -A
git commit -m "Preparing for next development iteration"
git push origin
- name: pull-request
env:
GH_TOKEN: ${{ github.token }}
run: |
gh_pr_up() {
gh pr create "$@" || gh pr edit "$@"
}
gh_pr_up -B "develop" \
--title "Sync back" \
--body "An automated PR to sync changes back"