-
Notifications
You must be signed in to change notification settings - Fork 1
113 lines (95 loc) · 3.24 KB
/
releases.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
name: Releases
on:
push:
branches:
- main
- master
paths:
- "*/v*.*.*/release.yaml"
workflow_dispatch:
jobs:
get-releases:
name: Get releases
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get releases
id: get-releases
# TODO: Replace specific providers in glob with * as soon as it matches all of them anyway.
run: echo releases="$(jq --null-input --args '$ARGS.positional' --compact-output -- {azure,capa,vsphere}/v*.*.*)" >> "${GITHUB_OUTPUT}"
outputs:
releases: ${{ steps.get-releases.outputs.releases }}
create-release:
name: Create release
runs-on: ubuntu-latest
needs: get-releases
strategy:
matrix:
release: ${{ fromJSON(needs.get-releases.outputs.releases) }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get provider & version
id: get-provider-version
env:
release: ${{ matrix.release }}
run: |
# Get provider & version.
provider="${release%/v*.*.*}"
version="${release#${provider}/}"
# Map provider.
# TODO: Remove once `capa` gets renamed to `aws`.
case "${provider}" in
capa)
provider="aws"
;;
esac
# Store provider & version.
echo provider="${provider}" >> "${GITHUB_OUTPUT}"
echo version="${version}" >> "${GITHUB_OUTPUT}"
- name: Get release
id: get-release
env:
GH_TOKEN: ${{ secrets.TAYLORBOT_GITHUB_ACTION }}
provider: ${{ steps.get-provider-version.outputs.provider }}
version: ${{ steps.get-provider-version.outputs.version }}
run: |
# Define tag.
tag="${provider}/${version}"
# Determine exists.
[ "$(gh release view "${tag}" --json id)" ] && exists=true || exists=false
# Store tag & exists.
echo tag="${tag}" >> "${GITHUB_OUTPUT}"
echo exists="${exists}" >> "${GITHUB_OUTPUT}"
- name: Create release
if: ${{ ! fromJSON(steps.get-release.outputs.exists) }}
env:
GH_TOKEN: ${{ secrets.TAYLORBOT_GITHUB_ACTION }}
release: ${{ matrix.release }}
provider: ${{ steps.get-provider-version.outputs.provider }}
version: ${{ steps.get-provider-version.outputs.version }}
tag: ${{ steps.get-release.outputs.tag }}
run: |
# Map title.
case "${provider}" in
aws)
title="AWS ${version}"
;;
azure)
title="Azure ${version}"
;;
vsphere)
title="vSphere ${version}"
;;
*)
title="${provider} ${version}"
;;
esac
# Define notes & files.
notes="${release}/README.md"
files=("${release}/release.yaml")
# Determine pre-release.
[[ "${version}" == v*.*.*-* ]] && prerelease="--prerelease" || prerelease=""
# Create release.
gh release create --target "${GITHUB_REF_NAME}" "${tag}" --title "${title}" --notes-file "${notes}" ${files[@]} ${prerelease}