-
Notifications
You must be signed in to change notification settings - Fork 3
140 lines (117 loc) · 5.63 KB
/
package-and-upload-assets.yml
File metadata and controls
140 lines (117 loc) · 5.63 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
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
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
name: Package and Upload Release Assets
# Global variables
env:
PACKAGE_NAME: "cloud-sql-sqlserver"
FILES_TO_PACKAGE: "gemini-extension.json CLOUD-SQL-SQLSERVER.md LICENSE"
GCS_BUCKET_URL: "https://storage.googleapis.com/genai-toolbox/geminicli"
on:
release:
types: [created]
jobs:
package:
name: Package for ${{ matrix.platform.os }}-${{ matrix.platform.arch }}
runs-on: ubuntu-latest
strategy:
matrix:
platform:
- { os: "linux", arch: "x64", download_path_segment: "linux/amd64", binary_suffix: "", archive_extension: "tar.gz", archive_command: 'tar -czvf "${ARCHIVE_NAME}" -C staging .' }
- { os: "darwin", arch: "arm64", download_path_segment: "darwin/arm64", binary_suffix: "", archive_extension: "tar.gz", archive_command: 'tar -czvf "${ARCHIVE_NAME}" -C staging .' }
- { os: "darwin", arch: "x64", download_path_segment: "darwin/amd64", binary_suffix: "", archive_extension: "tar.gz", archive_command: 'tar -czvf "${ARCHIVE_NAME}" -C staging .' }
- { os: "win32", arch: "x64", download_path_segment: "windows/amd64", binary_suffix: ".exe", archive_extension: "zip", archive_command: '(cd staging && zip ../"${ARCHIVE_NAME}" *)' }
steps:
- name: Checkout code at the new tag
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
ref: ${{ github.event.release.tag_name }}
- name: Set Dynamic Environment Variables
id: vars
run: |
echo "archive_name=${{ matrix.platform.os }}.${{ matrix.platform.arch }}.${{ env.PACKAGE_NAME }}.${{ matrix.platform.archive_extension }}" >> $GITHUB_OUTPUT
echo "source_binary=toolbox${{ matrix.platform.binary_suffix }}" >> $GITHUB_OUTPUT
- name: Get Toolbox Version
id: get_toolbox_version
run: |
TOOLBOX_VERSION=$(cat toolbox_version.txt)
echo "Found toolbox version: ${TOOLBOX_VERSION}"
echo "TOOLBOX_VERSION=${TOOLBOX_VERSION}" >> $GITHUB_OUTPUT
- name: Download Source Binary
env:
TOOLBOX_VERSION: ${{ steps.get_toolbox_version.outputs.TOOLBOX_VERSION }}
DOWNLOAD_PATH_SEGMENT: ${{ matrix.platform.download_path_segment }}
SOURCE_BINARY: ${{ steps.vars.outputs.source_binary }}
run: |
DOWNLOAD_URL="${GCS_BUCKET_URL}/v${TOOLBOX_VERSION}/${DOWNLOAD_PATH_SEGMENT}/${SOURCE_BINARY}"
echo "Downloading binary from: ${DOWNLOAD_URL}"
curl -L --fail -o "${SOURCE_BINARY}" "${DOWNLOAD_URL}"
chmod +x ${SOURCE_BINARY}
echo "Binary downloaded and prepared."
ls -l
- name: Create release archive
id: create_archive
env:
ARCHIVE_COMMAND: ${{ matrix.platform.archive_command }}
ARCHIVE_NAME: ${{ steps.vars.outputs.archive_name }}
SOURCE_BINARY: ${{ steps.vars.outputs.source_binary }}
run: |
ARCHIVE_NAME="${{ matrix.platform.os }}.${{ matrix.platform.arch }}.${PACKAGE_NAME}.${{ matrix.platform.archive_extension }}"
SOURCE_BINARY="toolbox${{ matrix.platform.binary_suffix }}"
echo "Packaging ${SOURCE_BINARY} into ${ARCHIVE_NAME}"
mkdir staging
cp "${SOURCE_BINARY}" "staging/${SOURCE_BINARY}"
cp ${FILES_TO_PACKAGE} staging/
if [[ "${{ matrix.platform.os }}" == "win32" ]]; then
echo "Modifying gemini-extension.json for Windows..."
jq '(.mcpServers[].command) |= sub("toolbox$"; "toolbox.exe")' gemini-extension.json > staging/gemini-extension.json
echo "Modification complete."
fi
echo "All assets staged."
ls -l staging
# Create archive
eval "${ARCHIVE_COMMAND}"
echo "Created archive: ${ARCHIVE_NAME}"
echo "ARCHIVE_PATH=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
- name: Upload archive as workflow artifact
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6
with:
name: ${{ steps.vars.outputs.archive_name }}
path: ${{ steps.create_archive.outputs.ARCHIVE_PATH }}
# This job gathers all archives and uploads them to the GitHub Release.
upload:
name: Upload all assets to release
runs-on: ubuntu-latest
needs: package
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Download all archives from workflow artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7
with:
path: release-archives
- name: List downloaded files
run: |
echo "--- Downloaded files ---"
ls -R release-archives
echo "------------------------"
- name: Upload all assets to GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_EVENT_RELEASE_TAG_NAME: ${{ github.event.release.tag_name }}
run: |
gh release upload \
${GITHUB_EVENT_RELEASE_TAG_NAME} \
release-archives/*/*