88 workflow_dispatch :
99
1010jobs :
11- goreleaser :
11+ # Build and publish Unix (Linux/macOS) binaries and Docker images.
12+ # This job creates the GitHub release that goreleaser-windows will upload to.
13+ goreleaser-unix :
1214 runs-on :
1315 group : databricks-deco-testing-runner-group
1416 labels : ubuntu-latest-deco
2729 uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
2830 with :
2931 go-version-file : go.mod
30-
31- # The default cache key for this action considers only the `go.sum` file.
32- # We include .goreleaser.yaml here to differentiate from the cache used by the push action
33- # that runs unit tests. This job produces and uses a different cache.
3432 cache-dependency-path : |
3533 go.sum
36- .goreleaser.yaml
34+ .goreleaser-unix .yaml
3735
3836 # Log into the GitHub Container Registry. The goreleaser action will create
3937 # the docker images and push them to the GitHub Container Registry.
@@ -48,12 +46,100 @@ jobs:
4846 - name : Set up QEMU dependency
4947 uses : docker/setup-qemu-action@29109295f81e9208d7d86ff1c6c12d2833863392 # v3.6.0
5048
51- - name : Run GoReleaser
49+ - name : Run GoReleaser for Unix
5250 id : releaser
5351 uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
5452 with :
5553 version : ~> v2
56- args : release
54+ args : release -f .goreleaser-unix.yaml
55+ env :
56+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
57+
58+ # Build and sign Windows binaries using AzureSignTool with Azure Key Vault.
59+ # Runs on GitHub-hosted windows-latest runner (has signtool and Windows SDK).
60+ # Uses --skip=publish to avoid creating duplicate GitHub release.
61+ # Waits for goreleaser-unix to create the release first.
62+ goreleaser-windows :
63+ environment : sign
64+ runs-on : windows-latest
65+
66+ steps :
67+ - name : Checkout repository and submodules
68+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
69+ with :
70+ fetch-depth : 0
71+ fetch-tags : true
72+
73+ - name : Setup Go
74+ uses : actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
75+ with :
76+ go-version-file : go.mod
77+ cache-dependency-path : |
78+ go.sum
79+ .goreleaser-windows.yaml
80+
81+ - name : Azure Login and get Key Vault token
82+ shell : pwsh
83+ run : |
84+ az login --service-principal `
85+ -u ${{ secrets.DECO_SIGN_AZURE_CLIENT_ID }} `
86+ -p ${{ secrets.DECO_SIGN_AZURE_CLIENT_SECRET }} `
87+ --tenant ${{ secrets.DECO_SIGN_AZURE_TENANT_ID }}
88+
89+ $accessToken = az account get-access-token --resource https://vault.azure.net --query accessToken -o tsv
90+ echo "::add-mask::$accessToken"
91+ echo "AZURE_VAULT_TOKEN=$accessToken" >> $env:GITHUB_ENV
92+
93+ - name : Install AzureSignTool
94+ shell : pwsh
95+ run : |
96+ dotnet tool install --global AzureSignTool
97+
98+ - name : Run GoReleaser for Windows
99+ uses : goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
100+ with :
101+ version : ~> v2
102+ args : release -f .goreleaser-windows.yaml --skip=publish
103+ env :
104+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
105+ AZURE_TENANT_ID : ${{ secrets.DECO_SIGN_AZURE_TENANT_ID }}
106+ AZURE_CLIENT_ID : ${{ secrets.DECO_SIGN_AZURE_CLIENT_ID }}
107+ AZURE_CLIENT_SECRET : ${{ secrets.DECO_SIGN_AZURE_CLIENT_SECRET }}
108+
109+ - name : Upload Windows artifacts to GitHub Actions
110+ uses : actions/upload-artifact@v4
111+ with :
112+ name : windows-artifacts
113+ path : |
114+ dist/*.zip
115+ dist/*SHA256SUMS*
116+ retention-days : 1
117+
118+ # Upload Windows artifacts to the GitHub release.
119+ # Separated from goreleaser-windows because GitHub-hosted runners are not allowlisted
120+ # for GitHub API access due to IP restrictions. Self-hosted runners have allowlisted IPs.
121+ # Flow: goreleaser-windows (build) -> GitHub Actions artifacts -> self-hosted runner (upload)
122+ upload-windows-to-release :
123+ runs-on :
124+ group : databricks-deco-testing-runner-group
125+ labels : ubuntu-latest-deco
126+ needs : [goreleaser-windows, goreleaser-unix]
127+
128+ steps :
129+ - name : Download Windows artifacts
130+ uses : actions/download-artifact@v4
131+ with :
132+ name : windows-artifacts
133+ path : dist
134+
135+ - name : Upload to GitHub release
136+ run : |
137+ for file in dist/*.zip dist/*SHA256SUMS*; do
138+ if [ -f "$file" ]; then
139+ echo "Uploading $(basename $file)"
140+ gh release upload ${{ github.ref_name }} "$file"
141+ fi
142+ done
57143 env :
58144 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
59145
62148 group : databricks-deco-testing-runner-group
63149 labels : ubuntu-latest-deco
64150
65- needs : goreleaser
151+ needs : [ goreleaser-windows, goreleaser-unix]
66152
67153 steps :
68154 - name : Set VERSION variable from tag
90176 group : databricks-deco-testing-runner-group
91177 labels : ubuntu-latest-deco
92178
93- needs : goreleaser
179+ needs : goreleaser-unix
94180
95181 steps :
96182 - name : Set VERSION variable from tag
@@ -103,7 +189,7 @@ jobs:
103189 with :
104190 github-token : ${{ secrets.DECO_GITHUB_TOKEN }}
105191 script : |
106- let artifacts = ${{ needs.goreleaser.outputs.artifacts }}
192+ let artifacts = ${{ needs.goreleaser-unix .outputs.artifacts }}
107193 artifacts = artifacts.filter(a => a.type == "Archive")
108194 artifacts = new Map(
109195 artifacts.map(a => [
@@ -131,7 +217,7 @@ jobs:
131217 group : databricks-deco-testing-runner-group
132218 labels : ubuntu-latest-deco
133219
134- needs : goreleaser
220+ needs : [ goreleaser-windows, goreleaser-unix]
135221
136222 steps :
137223 - name : Set VERSION variable from tag
@@ -159,7 +245,7 @@ jobs:
159245 group : databricks-deco-testing-runner-group
160246 labels : ubuntu-latest-deco
161247
162- needs : goreleaser
248+ needs : [ goreleaser-windows, goreleaser-unix]
163249
164250 # IMPORTANT:
165251 # - 'id-token: write' is mandatory for OIDC and trusted publishing to PyPi
@@ -190,3 +276,70 @@ jobs:
190276 uses : pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
191277 with :
192278 packages-dir : python/dist
279+
280+ publish-to-winget-pkgs :
281+ runs-on :
282+ group : databricks-deco-testing-runner-group
283+ labels : ubuntu-latest-deco
284+
285+ needs : upload-windows-to-release
286+
287+ environment : release
288+
289+ steps :
290+ - name : Checkout repository and submodules
291+ uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
292+
293+ # When updating the version of komac, make sure to update the checksum in the next step.
294+ # Find both at https://github.com/russellbanks/Komac/releases.
295+ - name : Download komac binary
296+ run : |
297+ curl -s -L -o $RUNNER_TEMP/komac-2.9.0-x86_64-unknown-linux-gnu.tar.gz https://github.com/russellbanks/Komac/releases/download/v2.9.0/komac-2.9.0-x86_64-unknown-linux-gnu.tar.gz
298+
299+ - name : Verify komac binary
300+ run : |
301+ echo "d07a12831ad5418fee715488542a98ce3c0e591d05c850dd149fe78432be8c4c $RUNNER_TEMP/komac-2.9.0-x86_64-unknown-linux-gnu.tar.gz" | sha256sum -c -
302+
303+ - name : Untar komac binary to temporary path
304+ run : |
305+ mkdir -p $RUNNER_TEMP/komac
306+ tar -xzf $RUNNER_TEMP/komac-2.9.0-x86_64-unknown-linux-gnu.tar.gz -C $RUNNER_TEMP/komac
307+
308+ - name : Add komac to PATH
309+ run : echo "$RUNNER_TEMP/komac" >> $GITHUB_PATH
310+
311+ - name : Confirm komac version
312+ run : komac --version
313+
314+ # Use the tag from the input, or the ref name if the input is not provided.
315+ # The ref name is equal to the tag name when this workflow is triggered by the "sign-cli" command.
316+ - name : Strip "v" prefix from version
317+ id : strip_version
318+ run : echo "version=$(echo ${{ github.ref_name }} | sed 's/^v//')" >> "$GITHUB_OUTPUT"
319+
320+ - name : Get URLs of signed Windows binaries
321+ id : get_windows_urls
322+ run : |
323+ urls=$(
324+ gh api https://api.github.com/repos/databricks/cli/releases/tags/${{ github.ref_name }} | \
325+ jq -r .assets[].browser_download_url | \
326+ grep -E '_windows_.*\.zip$' | \
327+ tr '\n' ' '
328+ )
329+ if [ -z "$urls" ]; then
330+ echo "No signed Windows binaries found" >&2
331+ exit 1
332+ fi
333+ echo "urls=$urls" >> "$GITHUB_OUTPUT"
334+ env :
335+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
336+
337+ - name : Publish to Winget
338+ run : |
339+ komac update Databricks.DatabricksCLI \
340+ --version ${{ steps.strip_version.outputs.version }} \
341+ --submit \
342+ --urls ${{ steps.get_windows_urls.outputs.urls }} \
343+ env :
344+ KOMAC_FORK_OWNER : eng-dev-ecosystem-bot
345+ GITHUB_TOKEN : ${{ secrets.ENG_DEV_ECOSYSTEM_BOT_TOKEN }}
0 commit comments