-
Notifications
You must be signed in to change notification settings - Fork 31
175 lines (159 loc) · 5.46 KB
/
release_prerelease.yaml
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
name: "🚀🟡 Prerelease"
on:
workflow_dispatch:
inputs:
version:
type: string
description: "Version to release, in format 'vX.Y.Z'"
version_shift:
type: choice
description: "Version shift, used if version is not specified"
options:
- "major"
- "minor"
- "patch"
default: "minor"
branch:
type: string
description: "Target branch to release"
default: "main"
with_release:
type: boolean
description: "Create green release as well"
default: false
jobs:
get_version:
name: "Get version"
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Checkout code
id: checkout
if: ${{ github.event.inputs.version == '' }}
uses: actions/checkout@v2
with:
ref: "${{ github.event.inputs.branch }}"
fetch-depth: 0
- name: Get version
id: get_version
run: |
version=${{ github.event.inputs.version }}
if [[ -z "${version}" ]]; then
latest_tag=$(git describe --tags --abbrev=0)
latest_version="${latest_tag%-rc.*}"
echo "Latest version is ${latest_version}"
version=$(.github/.scripts/shift_version.sh ${latest_version} ${{ github.event.inputs.version_shift }})
fi
if [[ ! $version =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "ERROR: Version must be in format vX.Y.Z, found $version, exiting..."
exit 1;
fi
echo "::notice title=Will prerelease the following version::$version"
echo "version=${version}" >> $GITHUB_OUTPUT
build_images:
name: "Build images"
needs: [get_version]
runs-on: ubuntu-latest
permissions:
packages: write
outputs:
image-version: ${{ steps.build_image.outputs.image-version }}
strategy:
matrix:
include:
- image_name: "datalens-control-api"
bake_target: "dl_control_api"
- image_name: "datalens-data-api"
bake_target: "dl_data_api"
container:
image: "ghcr.io/${{ github.repository_owner }}/${{ github.event.repository.name }}/debian_docker:latest"
options: -v /var/run/docker.sock:/var/run/docker.sock
credentials:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
env:
version: "${{ needs.get_version.outputs.version }}"
cr_url: "ghcr.io/${{ github.repository_owner }}"
steps:
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.cr_url }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout code
id: checkout
uses: actions/checkout@v2
with:
ref: "${{ github.event.inputs.branch }}"
fetch-depth: 0
- name: Build image
id: build_image
working-directory: docker_build
run: |
bake_target=${{ matrix.bake_target }}
version="${{ env.version }}"
image_version="${version#"v"}"
image_url_rc="${{ env.cr_url }}/${{ matrix.image_name }}:${image_version}-rc.1"
image_url_release="${{ env.cr_url }}/${{ matrix.image_name }}:${image_version}"
./run-project-bake "${bake_target}" \
--push \
--set "${bake_target}.tags=${image_url_rc}"
${{ github.event.inputs.with_release == 'true' && '--set "${bake_target}.tags=${image_url_release}"' || '' }}
echo "image-version=${image_version}" >> $GITHUB_OUTPUT
release:
name: "Create prerelease"
needs: [build_images, get_version]
runs-on: ubuntu-latest
permissions:
contents: write
env:
version: "${{ needs.get_version.outputs.version }}"
release_branch: "release/${{ needs.get_version.outputs.version }}"
steps:
- name: Checkout code
id: checkout
uses: actions/checkout@v2
with:
ref: "${{ github.event.inputs.branch }}"
fetch-depth: 0
- name: Create and push release branch
id: create_branch
if: ${{ github.event.inputs.branch != env.release_branch }}
run: |
git branch ${{ env.release_branch }}
git push origin ${{ env.release_branch }}
- name: Create prerelease
id: create_prerelease
run: |
gh release create \
--repo ${{ github.repository_owner }}/${{ github.event.repository.name }} \
${{ env.release_tag }} \
--target ${{ env.release_branch }} \
--prerelease \
--generate-notes
env:
GH_TOKEN: ${{ github.token }}
release_tag: "${{ env.version }}-rc.1"
- name: Create release
id: create_release
if: ${{ github.event.inputs.with_release == 'true' }}
run: |
gh release create \
--repo ${{ github.repository_owner }}/${{ github.event.repository.name }} \
${{ env.release_tag }} \
--target ${{ env.release_branch }} \
--generate-notes
env:
GH_TOKEN: ${{ github.token }}
release_tag: "${{ env.version }}"
run_e2e_tests:
name: "Run E2E tests"
needs: [ build_images, get_version ]
uses: datalens-tech/datalens-backend/.github/workflows/run_e2e.yml@fix_e2e
with:
image_version: ${{ needs.build_images.outputs.image-version }}
secrets: inherit