-
Notifications
You must be signed in to change notification settings - Fork 1
167 lines (156 loc) · 5.61 KB
/
release-upload-asset.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
name: Upload Windows MSI to Dolt Release
permissions:
id-token: write # This is required for requesting the JWT
contents: read # This is required for actions/checkout
on:
repository_dispatch:
types: [ upload-msi ]
workflow_dispatch:
inputs:
version:
description: 'SemVer format dolt release tag, i.e. 0.24.5'
required: true
profile_bucket:
description: 'bucket of profile key for pgo builds'
required: true
profile_key:
description: 'key of profile for pgo builds'
required: true
commitish:
description: 'the dolt commit used to build the msi. if provided, used instead of version number'
required: false
default: ''
jobs:
get-release-id:
name: Get Dolt Release Id
runs-on: ubuntu-22.04
outputs:
release_id: ${{ steps.get_release.outputs.release_id }}
steps:
- name: Get Release
id: get_release
run: |
release_id="$RELEASE_ID"
if [ "$EVENT_TYPE" == "workflow_dispatch" ]; then
release_id=$(curl -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/dolthub/dolt/releases/tags/v${{ github.event.inputs.version }} | jq '.id')
fi
echo "release_id=$release_id" >> $GITHUB_OUTPUT
env:
EVENT_TYPE: ${{ github.event_name }}
RELEASE_ID: ${{ github.event.client_payload.release_id }}
get-version:
name: Get Version
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.get_version.outputs.version }}
steps:
- name: Get version
id: get_version
run: |
version=""
if [ "${{ github.event_name }}" == "repository_dispatch" ]
then
version="${{ github.event.client_payload.tag }}"
else
version="${{ github.event.inputs.version }}"
fi
echo "version=$version" >> $GITHUB_OUTPUT
build-release-binaries:
needs: get-version
name: Build Release Binaries
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
repository: dolthub/dolt
ref: ${{ github.event.inputs.commitish || format('v{0}', needs.get-version.outputs.version) }}
token: ${{ secrets.REPO_ACCESS_TOKEN }}
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-session-name: GitHub_to_AWS_via_FederatedOIDC
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME_CORP }}
aws-region: us-west-2
- name: Get Results
id: get-results
run: aws s3api get-object --bucket="$BUCKET" --key="$KEY" dolt-cpu-profile.pprof
env:
KEY: ${{ github.event.inputs.profile_key || github.event.client_payload.profile_key }}
BUCKET: ${{ github.event.inputs.profile_bucket || github.event.client_payload.bucket }}
- name: Build PGO Binaries
id: build_binaries
run: |
latest=$(git rev-parse HEAD)
echo "commitish=$latest" >> $GITHUB_OUTPUT
GO_BUILD_VERSION=1.23.3 go/utils/publishrelease/buildpgobinaries.sh
env:
GO_BUILD_VERSION: "1.23.3"
PROFILE: ${{ format('{0}/dolt-cpu-profile.pprof', github.workspace) }}
- uses: actions/upload-artifact@v4
with:
name: dolt-windows-amd64-latest
path: go/out/dolt-windows-amd64.zip
upload-windows-msi:
needs: [get-version, get-release-id, build-release-binaries]
name: Upload Windows MSI to Dolt Release
runs-on: windows-2019
defaults:
run:
shell: powershell
steps:
- uses: actions/checkout@v2
- name: Build Windows MSI
run: |
mkdir archives
mkdir output
- uses: actions/download-artifact@v4
with:
name: dolt-windows-amd64-latest
path: archives/dolt-windows-amd64.zip
- name: Run Process.bat
run: |
./process.bat
- name: Upload MSI to Dolt Release
uses: actions/github-script@v4
with:
debug: true
github-token: ${{ secrets.REPO_ACCESS_TOKEN }}
script: |
const fs = require('fs');
const path = require('path')
try {
const data = fs.readFileSync(path.join(process.env.WORKSPACE, "output", "dolt-windows-amd64.msi"))
const res = await github.repos.uploadReleaseAsset({
owner: "dolthub",
repo: "dolt",
name: "dolt-windows-amd64.msi",
release_id: parseInt(process.env.RELEASE_ID, 10),
data,
});
console.log("Successfully uploaded windows msi", res)
} catch (err) {
console.log("Error", err);
process.exit(1);
}
env:
WORKSPACE: ${{ github.workspace }}
RELEASE_ID: ${{ needs.get-release-id.outputs.release_id }}
bump-dolt-packages:
needs: [get-version, upload-windows-msi]
runs-on: ubuntu-22.04
steps:
- name: Trigger Bump Winget
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: bump-winget
repository: dolthub/dolt
client-payload: '{"version": "${{ needs.get-version.outputs.version }}"}'
- name: Trigger Bump Chocolatey
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
event-type: bump-chocolatey
repository: dolthub/chocolatey-packages
client-payload: '{"version": "${{ needs.get-version.outputs.version }}"}'