-
Notifications
You must be signed in to change notification settings - Fork 609
123 lines (98 loc) · 2.82 KB
/
publish-cli.yml
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
name: Vespa CLI - Build and Publish
on:
push:
tags:
- v*
pull_request:
branches:
- master
paths:
- .github/workflows/publish-cli.yml
- client/go/**
defaults:
run:
# Specify to ensure "pipefail and errexit" are set.
# Ref: https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#defaultsrunshell
shell: bash
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
build-version: ${{ steps.meta.outputs.version }}
steps:
- name: Define Build Version
id: meta
run: |
if [[ "${{ github.event_name }}" == "push" && "${{ startswith(github.ref, 'refs/tags/v') }}" == "true" ]]; then
# Remove the "v" prefix from the tag.
BUILD_VERSION="${GITHUB_REF_NAME#v}"
else
BUILD_VERSION="0.0.0-dev_${{ github.run_number }}"
fi
echo "version=${BUILD_VERSION}" >> $GITHUB_OUTPUT
build-test:
runs-on: ubuntu-latest
needs:
- prepare
defaults:
run:
# This workflow only interacts with the client/go directory, so we can set the working directory here.
working-directory: client/go
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
- name: build
env:
VERSION: ${{ needs.prepare.outputs.build-version }}
run: |
make clean dist
- name: test
run: |
make test
- uses: actions/upload-artifact@v4
with:
name: vespa-cli
path: client/go/dist
retention-days: 1
publish:
runs-on: macos-latest
if: github.event_name == 'push' && startswith(github.ref, 'refs/tags/v')
needs:
- prepare
- build-test
permissions:
contents: write
defaults:
run:
# This workflow only interacts with the client/go directory, so we can set the working directory here.
working-directory: client/go
env:
VERSION: ${{ needs.prepare.outputs.build-version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: vespa-cli
path: client/go/dist
- name: install-dependencies
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_AUTO_UPDATE: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
run: |
brew install --quiet coreutils gh zip go
- name: Publish to GitHub Releases
env:
GH_TOKEN: ${{ github.token }}
run: |
make clean dist-github
- name: Publish to Homebrew
env:
HOMEBREW_GITHUB_API_TOKEN: ${{ secrets.HOMEBREW_GITHUB_API_TOKEN }}
run: |
make clean dist-homebrew
- name: Install via Homebrew
run: |
make install-brew