-
Notifications
You must be signed in to change notification settings - Fork 49
145 lines (144 loc) · 5.31 KB
/
assets.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
---
name: assets
on:
release:
types:
- created
workflow_dispatch:
inputs:
tag:
description: 'Release tag to checkout'
required: true
type: string
env:
# e.g. v1.0.0 (use release tag on release events or the provided tag on manual invocation)
TAG_NAME: ${{ github.event.release.tag_name || github.event.inputs.tag }}
jobs:
get-upload-url:
outputs:
automated_upload_url: ${{ steps.automated-upload-url.outputs.AUTO_UPLOAD_URL }}
manual_upload_url: ${{ steps.manual-upload-url.outputs.MANUAL_UPLOAD_URL }}
runs-on: ubuntu-latest
steps:
- name: Get upload URL for automated releases
id: automated-upload-url
if: ${{ github.event.release.tag_name }}
run: echo "AUTO_UPLOAD_URL=${{ github.event.release.upload_url }}" >> "$GITHUB_OUTPUT"
- name: Get upload URL for manually triggered releases
id: manual-upload-url
if: ${{ github.event.inputs.tag }}
uses: actions/github-script@v7
with:
script: |
const release = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: "${{ github.event.inputs.tag }}"
});
core.setOutput("MANUAL_UPLOAD_URL", release.data.upload_url);
proto-assets:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- uses: actions/checkout@v4
- name: Init submodule
run: git submodule init && git submodule update
- name: Set raw version
id: raw_tag
# Strips the 'v' from the actual semver version.
run: echo ::set-output name=raw_version::"${TAG_NAME#v}"
- name: Install Protoc
uses: arduino/setup-protoc@v1
- name: Compile proto release assets
run: go run ./util/cmd/release -version=${{ steps.raw_tag.outputs.raw_version }}
- name: Upload proto release assets
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ github.token }}
file: ./dist/*
tag: ${{ env.TAG_NAME }}
overwrite: true
file_glob: true
binary-assets:
runs-on: ubuntu-latest
needs: [get-upload-url, proto-assets]
env:
AUTO_UPLOAD_URL: ${{ needs.get-upload-url.outputs.automated_upload_url }}
MANUAL_UPLOAD_URL: ${{ needs.get-upload-url.outputs.manual_upload_url }}
GITHUB_TOKEN: ${{ github.token }}
strategy:
matrix:
osarch:
- os: linux
arch: amd64
- os: linux
arch: arm
- os: darwin
arch: amd64
- os: darwin
arch: arm64
- os: windows
arch: amd64
steps:
- name: Determine which upload URL to use
id: determine_upload_url
run: |
echo "automated URL: $AUTO_UPLOAD_URL"
echo "manual URL: $MANUAL_UPLOAD_URL"
if [[ -n "$AUTO_UPLOAD_URL" ]]; then
echo "GITHUB_UPLOAD_URL=$AUTO_UPLOAD_URL" >> "$GITHUB_OUTPUT"
else
echo "GITHUB_UPLOAD_URL=$MANUAL_UPLOAD_URL" >> "$GITHUB_OUTPUT"
fi
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Install gox
run: go install github.com/mitchellh/gox@latest
- uses: actions/checkout@v4
- name: Set raw version
id: raw_tag
# Strips the 'v' from the actual semver version.
run: echo ::set-output name=raw_version::"${TAG_NAME#v}"
# The generator does not use this, but we need it to build the
# binaries.
#
# Mousetrap is installed individually because it is needed for the
# Windows build. Since we are building on Linux, it is not installed
# automatically as a dependency.
- name: Install the cross-platform build dependency.
run: go get github.com/inconshreveable/mousetrap
- name: Build for the ${{ matrix.osarch.os }}/${{ matrix.osarch.arch }} platform.
run: |
gox -osarch ${{ matrix.osarch.os }}/${{ matrix.osarch.arch }} -output gapic-showcase ./cmd/gapic-showcase && \
tar cvfz gapic-showcase.tar.gz gapic-showcase*
- name: Upload the ${{ matrix.osarch.os }}/${{ matrix.osarch.arch }} release.
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.determine_upload_url.outputs.GITHUB_UPLOAD_URL }}
asset_path: ./gapic-showcase.tar.gz
asset_name: gapic-showcase-${{ steps.raw_tag.outputs.raw_version }}-${{ matrix.osarch.os }}-${{ matrix.osarch.arch }}.tar.gz
asset_content_type: application/tar+gzip
# Note: Disabled until better solution for storing the GCR key is found.
# push_to_registry:
# needs:
# - inspect
# - release
# runs-on: ubuntu-latest
# steps:
# - name: Check out the repo
# uses: actions/checkout@v2
# - name: Login to GCR
# uses: docker/login-action@v1
# with:
# registry: gcr.io
# username: _json_key
# password: ${{ secrets.GCR_JSON_KEY }}
# - name: Push to GCR
# uses: docker/build-push-action@v2
# with:
# tags: gcr.io/gapic-images/gapic-showcase:${{ needs.inspect.outputs.raw_version }},gcr.io/gapic-images/gapic-showcase:latest
# push: true
# context: .