-
Notifications
You must be signed in to change notification settings - Fork 46
197 lines (174 loc) · 6.23 KB
/
publish-release-packages.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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: Publish packages to public repositories
on:
workflow_call:
inputs:
artifactName:
required: true
type: string
description: "The github artifact holding the wheel file which will be published"
do_brew:
required: false
default: true
type: boolean
description: "Publish to brew repository"
do_chocolatey:
required: false
default: true
type: boolean
description: "Publish to Chocolatey repository"
do_snap:
required: false
default: true
type: boolean
description: "Publish to snap repository"
do_winget:
required: false
default: true
type: boolean
description: "Publish to Winget repository"
workflow_dispatch:
inputs:
release:
required: true
type: string
description: "The existing github release which will be published (e.g. v0.1.0)"
do_brew:
required: false
default: true
type: boolean
description: "Publish to brew repository"
do_chocolatey:
required: false
default: true
type: boolean
description: "Publish to Chocolatey repository"
do_snap:
required: false
default: true
type: boolean
description: "Publish to snap repository"
do_winget:
required: false
default: true
type: boolean
description: "Publish to Winget repository"
jobs:
publish-brew:
runs-on: ubuntu-latest
if: ${{ inputs.do_brew }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
# Download either via release or provided artifact
- name: Download release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: gh release download ${{ inputs.release }} --pattern "*.whl" --dir dist
env:
GH_TOKEN: ${{ github.token }}
- name: Download artifact
if: ${{ github.event_name == 'workflow_call' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifactName }}
path: dist
- name: Set Git user as GitHub actions
run: git config --global user.email "[email protected]" && git config --global user.name "github-actions"
- name: Update homebrew cask
run: scripts/update-brew-cask.sh "dist/algokit*-py3-none-any.whl" "algorandfoundation/homebrew-tap"
env:
TAP_GITHUB_TOKEN: ${{ secrets.TAP_GITHUB_TOKEN }}
publish-chocolatey:
runs-on: windows-latest
if: ${{ inputs.do_chocolatey }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
# Download either via release or provided artifact
- name: Download release
if: ${{ github.event_name == 'workflow_dispatch' }}
run: gh release download ${{ inputs.release }} --pattern "*.whl" --dir dist
env:
GH_TOKEN: ${{ github.token }}
- name: Download artifact
if: ${{ github.event_name == 'workflow_call' }}
uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifactName }}
path: dist
- name: Update chocolatey files
id: update_chocolatey_files
run: scripts/update-chocolatey-package.ps1
- name: Build package
uses: crazy-max/ghaction-chocolatey@v2
with:
args: pack --version ${{ steps.update_chocolatey_files.outputs.version }} .\scripts\chocolatey\algokit\algokit.nuspec
- name: Set API key
uses: crazy-max/ghaction-chocolatey@v2
with:
args: apikey --api-key ${{ secrets.CHOCOLATEY_API_KEY }} -source https://push.chocolatey.org/
- name: Push package
uses: crazy-max/ghaction-chocolatey@v2
with:
args: push --source https://push.chocolatey.org/
publish-snap:
runs-on: ubuntu-latest
if: ${{ inputs.do_snap }}
steps:
- name: Checkout source code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set release version
shell: bash
continue-on-error: true
run: |
if [ -z "${{ inputs.release }}" ]; then
echo "RELEASE_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1))" >> $GITHUB_ENV
git describe --tags $(git rev-list --tags --max-count=1)
else
echo "RELEASE_VERSION=${{ inputs.release }}" >> $GITHUB_ENV
fi
- name: Download binary artifact from release
if: ${{ env.RELEASE_VERSION != '' || (github.event_name == 'workflow_dispatch' && inputs.release != '') }}
run: |
gh release download ${{ env.RELEASE_VERSION || inputs.release }} --pattern "*-snap.tar.gz" --dir dist
BINARY_PATH=$(ls dist/*-snap.tar.gz)
echo "BINARY_PATH=$BINARY_PATH" >> $GITHUB_ENV
env:
GH_TOKEN: ${{ github.token }}
- name: Generate snapcraft.yaml
run: |
./scripts/snap/create-snapcraft-yaml.sh ${{ github.workspace }} ${{ env.RELEASE_VERSION }} ${{ env.BINARY_PATH }} "stable"
- name: Upload snapcraft.yaml as reference artifact
uses: actions/upload-artifact@v2
with:
name: snapcraft-yaml
path: ${{ github.workspace }}/snap/snapcraft.yaml
- name: Build snap
uses: snapcore/action-build@v1
with:
snapcraft-args: --target-arch amd64
- name: Set path to snap binary
shell: bash
run: |
echo "SNAP_BINARY_PATH=$(find ${{ github.workspace }} -name '*.snap')" >> $GITHUB_ENV
- name: Publish snap
uses: snapcore/action-publish@v1
env:
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_RELEASE_TOKEN }}
with:
snap: ${{ env.SNAP_BINARY_PATH }}
release: stable
publish-winget:
runs-on: windows-latest
if: ${{ inputs.do_winget }}
steps:
- name: Publish to winget
shell: pwsh
env:
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
run: |
echo 'Publishing to winget'
# The below can be uncommented after we've manually created the first release on winget
# & .\scripts\winget\update-package.ps1 `
# -releaseVersionTag '${{ inputs.release }}'