forked from SeldonIO/seldon-core
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (128 loc) · 5.16 KB
/
draft-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
name: V2 Draft New Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version for new draft (e.g. v0.1.0)'
required: true
env:
GITHUB_USER: seldondev
KUSTOMIZE_VERSION: 4.5.5
HELM_VERSION: v3.8.1
jobs:
draft-release:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Output Inputs
run: echo "${{ toJSON(github.event.inputs) }}"
- name: Checkout Git Commit
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate workflow inputs
shell: bash
run: |
set -e
RELEASE_BRANCH=${GITHUB_REF_NAME}
RELEASE_TAG="${{ github.event.inputs.version }}"
# Ensure that we do not run on master
if [ "${RELEASE_BRANCH}" == "master" ] || [ "${RELEASE_BRANCH}" == "v2" ]; then
echo "::error::Cannot run this workflow on master branch"
exit 1
fi
# TODO: validate that RELEASE BRANCH is for the release line
# Release tag version must match v<major>.<minor>.<patch> and optional -rcX suffix
if ! echo "${RELEASE_TAG}" | egrep '^v[0-9]+\.[0-9]+\.[0-9]+(-rc[0-9]+)*$'; then
echo "::error::Target version '${RELEASE_TAG}' is not valid release tag." >&2
exit 1
fi
# Ensure that release does not yet exist
if git rev-parse ${RELEASE_TAG}; then
echo "::error::Release tag ${RELEASE_TAG} already exists. Stopping draft process."
exit 1
fi
# Save env variables for later steps
echo "RELEASE_BRANCH=${RELEASE_BRANCH}" >> $GITHUB_ENV
echo "RELEASE_TAG=${RELEASE_TAG}" >> $GITHUB_ENV
- name: Configure Git
run: |
git config --global user.name "${GITHUB_USER}"
git config --global user.email "${GITHUB_USER}@users.noreply.github.com"
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 14
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- name: Setup Helm
uses: azure/setup-helm@v3
with:
version: "${{ env.HELM_VERSION }}"
- name: Setup Kustomize
run: |
curl -s "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh" | bash -s -- ${KUSTOMIZE_VERSION}
sudo mv kustomize /usr/local/bin/
- name: Set versions in helm charts and yaml manifests
run: |
make NEW_VERSION=${RELEASE_TAG#v} set-versions
git add k8s/helm-charts && git commit -m "Setting version for helm charts" || echo "Nothing to commit"
git add k8s/yaml && git commit -m "Setting version for yaml manifests" || echo "Nothing to commit"
- name: Prepare artifacts
run: |
make prep-artifacts
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: artifacts
path: .release/
- name: Install auto-changelog tool
run: |
npm install -g auto-changelog
- name: Check if release is for core version
run: |
if [[ ${RELEASE_TAG} == ${RELEASE_TAG%-*} ]]; then
echo "Core release"
echo "IS_RELEASE_CORE_VERSION=true" >> $GITHUB_ENV
else
echo "Non-core release"
echo "IS_RELEASE_CORE_VERSION=false" >> $GITHUB_ENV
fi
- name: Generate CHANGELOG.md
run: |
git commit -m "Generating changelog for ${RELEASE_TAG}" --allow-empty
if ${IS_RELEASE_CORE_VERSION}; then
git tag "${RELEASE_TAG}" --force && auto-changelog --tag-pattern ^v\([0-9]\+\.\){2}[0-9]\+$ --starting-version v2.0.0 --ending-version ${RELEASE_TAG} -l 5
else
git tag "${RELEASE_TAG}" --force && auto-changelog -l 5 --starting-version v2.0.0 --ending-version ${RELEASE_TAG}
fi
git add CHANGELOG.md && git commit --amend --no-edit || echo "Nothing to commit"
- name: Generate release-notes.txt
run: |
if ${IS_RELEASE_CORE_VERSION}; then
auto-changelog --tag-pattern ^v\([0-9]\+\.\){2}[0-9]\+$ --starting-version ${RELEASE_TAG} --ending-version ${RELEASE_TAG} -l 5 -o release-notes.txt
else
auto-changelog -l 5 --starting-version ${RELEASE_TAG} --ending-version ${RELEASE_TAG} -o release-notes.txt
fi
- name: Upload release notes
uses: actions/upload-artifact@v3
with:
name: release-notes
path: release-notes.txt
- name: Push new commits to repository
run: git push
- name: Create or edit release draft
run: |
# TODO: Valdiate that there is no published released (we should not get here if tag exists anyway)
gh release delete "${RELEASE_TAG}" --yes || echo "Draft does not yet exist"
gh release create "${RELEASE_TAG}" --draft \
--title "${RELEASE_TAG}" \
--notes-file release-notes.txt \
--target "${RELEASE_BRANCH}" \
.release/*
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}