-
Notifications
You must be signed in to change notification settings - Fork 0
114 lines (97 loc) · 3.83 KB
/
release.yml
File metadata and controls
114 lines (97 loc) · 3.83 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
name: release
on:
workflow_dispatch:
push:
branches: [master]
paths: ['chart/Chart.yaml']
jobs:
create-release:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
release_type: ${{ steps.get-version.outputs.release_type }}
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
- name: Check out Devolutions/actions
uses: actions/checkout@v4
with:
repository: Devolutions/actions
ref: v1
token: ${{ secrets.DEVOLUTIONSBOT_TOKEN }}
path: ./.github/workflows
- name: Set version
id: get-version
run: |
echo "version=$(grep '^version:' chart/Chart.yaml | awk '{print $2}')" >> "$GITHUB_OUTPUT"
release_type=$(echo "$COMMIT_MSG" | sed -n 's/.*bump \(Beta\|Stable\|LTS\) to.*/\1/p')
echo "release_type=${release_type}" >> "$GITHUB_OUTPUT"
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
- name: Check tag does not already exist
run: |
if gh release view "v${{ steps.get-version.outputs.version }}" &>/dev/null; then
echo "::error::Release v${{ steps.get-version.outputs.version }} already exists. Bump the version in chart/Chart.yaml first."
exit 1
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
uses: ./.github/workflows/create-release
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
tag: v${{ steps.get-version.outputs.version }}
- name: Add release type to notes
if: steps.get-version.outputs.release_type != ''
run: |
body=$(gh release view "$TAG" --json body -q '.body')
notes="**Release type: $RELEASE_TYPE**${body:+$'\n\n'$body}"
prerelease_flag=""
if [ "$RELEASE_TYPE" = "Beta" ]; then
prerelease_flag="--prerelease"
fi
gh release edit "$TAG" --notes "$notes" $prerelease_flag
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: v${{ steps.get-version.outputs.version }}
RELEASE_TYPE: ${{ steps.get-version.outputs.release_type }}
publish-helm-chart:
runs-on: ubuntu-latest
needs: create-release
environment: helm-publish
steps:
- name: Check out ${{ github.repository }}
uses: actions/checkout@v4
- name: Install Helm
uses: azure/setup-helm@v4
- name: Add pre-release suffix for Beta
if: ${{ needs.create-release.outputs.release_type == 'Beta' }}
run: 'sed -i "s/^version: .*/version: ${{ needs.create-release.outputs.version }}-beta/" chart/Chart.yaml'
- name: Package chart
run: helm package chart/
- name: Check out helm-charts repository
uses: actions/checkout@v4
with:
repository: Devolutions/helm-charts
token: ${{ secrets.DEVOLUTIONSBOT_WRITE_TOKEN }}
path: helm-charts
- name: Copy chart package
run: |
mkdir -p helm-charts/devolutions-server
cp devolutions-server-*.tgz helm-charts/devolutions-server/
- name: Update index
working-directory: helm-charts
run: |
if [ -f index.yaml ]; then
helm repo index . --url https://devolutions.github.io/helm-charts --merge index.yaml
else
helm repo index . --url https://devolutions.github.io/helm-charts
fi
- name: Commit and push
working-directory: helm-charts
run: |
git config user.name "devolutionsbot"
git config user.email "bot@devolutions.net"
git add devolutions-server/devolutions-server-*.tgz index.yaml
git commit -m "feat(devolutions-server): add version ${{ needs.create-release.outputs.version }}"
git push