-
Notifications
You must be signed in to change notification settings - Fork 52
165 lines (155 loc) · 5.6 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
#
# Copyright (c) 2020-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#
name: Release Che Dashboard
on:
workflow_dispatch:
inputs:
version:
description: 'The version that is going to be released. Should be in format 7.y.z'
required: true
default: '7.y.z'
forceRecreateTags:
description: If true, tags will be recreated. Use with caution
required: false
default: 'false'
env:
IMAGE: quay.io/eclipse/che-dashboard
jobs:
tag-release:
runs-on: ubuntu-22.04
steps:
-
name: "Checkout Che Dashboard source code"
uses: actions/checkout@v3
-
name: "Setup Node"
uses: actions/setup-node@v3
with:
node-version: "18"
-
name: "Install npm & lerna"
run: "npm install --global lerna"
-
name: Check existing tags
run: |
set +e
RECREATE_TAGS=${{ github.event.inputs.forceRecreateTags }}
VERSION=${{ github.event.inputs.version }}
EXISTING_TAG=$(git ls-remote --exit-code origin refs/tags/${VERSION})
if [[ -n ${EXISTING_TAG} ]]; then
if [[ ${RECREATE_TAGS} == "true" ]]; then
echo "[INFO] Removing tag for ${VERSION} version. New tag will be recreated during release."
git push origin :$VERSION
else
echo "[ERROR] Cannot proceed with release - tag ${EXISTING_TAG} already exists."
exit 1
fi
else
echo "[INFO] No existing tags detected for $VERSION"
fi
-
name: "Tag release"
run: |
git config --global user.name "Mykhailo Kuznietsov"
git config --global user.email "[email protected]"
git config --global pull.rebase true
export GITHUB_TOKEN=${{ secrets.CHE_BOT_GITHUB_TOKEN }}
/bin/bash make-release.sh --version ${{ github.event.inputs.version }} --tag-release
#- name: Create failure MM message
#if: ${{ failure() }}
#run: |
#echo "{\"text\":\":no_entry_sign: Che Dashboard ${{ github.event.inputs.version }} release has failed: https://github.com/eclipse/che-dashboard/actions/workflows/release.yml\"}" > mattermost.json
#- name: Create success MM message
#run: |
#echo "{\"text\":\":white_check_mark: Che Dashboard ${{ github.event.inputs.version }} has been released: https://quay.io/eclipse/che-dashboard:${{ github.event.inputs.version }}\"}" > mattermost.json
#- name: Send MM message
#if: ${{ success() }} || ${{ failure() }}
#uses: mattermost/[email protected]
#env:
#MATTERMOST_WEBHOOK_URL: ${{ secrets.MATTERMOST_WEBHOOK_URL }}
#MATTERMOST_CHANNEL: eclipse-che-releases
#MATTERMOST_USERNAME: che-bot
build-images:
runs-on: ubuntu-22.04
needs: tag-release
strategy:
fail-fast: false
matrix:
arch: [amd64,arm64]
outputs:
amd64: ${{ steps.result.outputs.amd64 }}
arm64: ${{ steps.result.outputs.arm64 }}
steps:
-
name: "Checkout Che Dashboard source code"
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.version }}
-
name: "Set up QEMU"
uses: docker/setup-qemu-action@v2
-
name: "Set up Docker Buildx ${{ matrix.arch }}"
uses: docker/setup-buildx-action@v2
-
name: "Docker quay.io Login"
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
-
name: "Build and push ${{ matrix.arch }}"
uses: docker/build-push-action@v3
with:
context: .
file: ./build/dockerfiles/Dockerfile
platforms: linux/${{ matrix.arch }}
push: true
provenance: false
tags: ${{ env.IMAGE }}:${{ github.event.inputs.version }}-${{ matrix.arch }}
-
id: result
name: "Build result outputs version"
if: ${{ success() }}
run: echo "${{ matrix.arch }}=${{ github.event.inputs.version }}-${{ matrix.arch }}" >> $GITHUB_OUTPUT
create-manifest:
needs: build-images
runs-on: ubuntu-22.04
steps:
-
name: "Docker quay.io Login"
uses: docker/login-action@v2
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}
-
name: "Create and push manifest"
run: |
AMD64_VERSION="${{ needs['build-images'].outputs.amd64 }}"
ARM64_VERSION="${{ needs['build-images'].outputs.arm64 }}"
if [[ -z "$AMD64_VERSION" || \
-z "$ARM64_VERSION" ]]; then
echo "[!] The job 'build-images' fails on some of the architectures. Can't create complete manifest.";
exit 1;
fi
AMEND=""
AMEND+=" --amend ${{ env.IMAGE }}:$AMD64_VERSION";
AMEND+=" --amend ${{ env.IMAGE }}:$ARM64_VERSION";
docker manifest create ${{ env.IMAGE }}:${{ github.event.inputs.version }} $AMEND
docker manifest push ${{ env.IMAGE }}:${{ github.event.inputs.version }}
-
id: result
name: "Manifest result"
if: ${{ success() }}
run: echo "Manifest was created and pushed successfully"