v0.35.5 #58
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
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: . |