-
Notifications
You must be signed in to change notification settings - Fork 5
154 lines (139 loc) · 4.93 KB
/
ci.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: ci
on:
push: {}
pull_request: {}
jobs:
lint:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
check-latest: true
cache: true
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 8.x.x
- name: Install Node 18
uses: actions/setup-node@v4
with:
node-version: "18"
cache: pnpm
cache-dependency-path: npm/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
working-directory: npm
- name: Verify dependencies
run: |
go mod verify
go mod download
- name: Check formatting
run: |
STATUS=0
assert-nothing-changed() {
local diff
"$@" >/dev/null || return 1
if ! diff="$(git diff -U1 --color --exit-code)"; then
printf '\e[31mError: running `\e[1m%s\e[22m` results in modifications that you must check into version control:\e[0m\n%s\n\n' "$*" "$diff" >&2
git checkout -- .
STATUS=1
fi
}
assert-nothing-changed go fmt ./...
assert-nothing-changed go mod tidy
exit $STATUS
- uses: golangci/golangci-lint-action@v5
with:
version: v1.56.2
only-new-issues: false
skip-cache: false
skip-build-cache: true
skip-pkg-cache: true
args: --timeout 5m
github-token: ${{ secrets.GITHUB_TOKEN }}
- run: pnpm fmt:check
working-directory: npm
- run: pnpm type-check
working-directory: npm
build:
runs-on: ubuntu-latest-16-cores
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: "1.21"
check-latest: true
cache: true
- name: Install pnpm
uses: pnpm/[email protected]
with:
version: 8.x.x
- name: Install Node 18
uses: actions/setup-node@v4
with:
node-version: "18"
cache: pnpm
cache-dependency-path: npm/pnpm-lock.yaml
- name: Install dependencies
run: pnpm install --frozen-lockfile --ignore-scripts
working-directory: npm
- uses: goreleaser/goreleaser-action@v5
with:
version: 1.19.0
args: build --clean --snapshot
- run: make npm
env:
DEPOT_CLI_VERSION: v0.0.0-dev
package:
runs-on: ubuntu-latest
if: github.event_name != 'pull_request'
permissions:
contents: read
packages: write
id-token: write
steps:
- uses: actions/checkout@v4
- uses: depot/setup-action@v1
- uses: docker/metadata-action@v5
id: meta
with:
images: |
ghcr.io/depot/cli
public.ecr.aws/depot/cli
github-token: ${{ secrets.GITHUB_TOKEN }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- id: build-info
name: Set build information
run: |
echo "::set-output name=version::${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.version'] }}"
echo "::set-output name=date::$(date +'%Y-%m-%d')"
echo "::set-output name=sentry-environment::${{ fromJSON('{"true":"release","false":"development"}')[startsWith(github.ref, 'refs/tags/v')] }}"
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::375021575472:role/github-actions
aws-region: us-east-1
- uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- uses: depot/build-push-action@v1
with:
push: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
build-args: |
LDFLAGS=-s -w -X github.com/depot/cli/internal/build.Version=${{ steps.build-info.outputs.version }} -X github.com/depot/cli/internal/build.Date=${{ steps.build-info.outputs.date }} -X github.com/depot/cli/internal/build.SentryEnvironment=${{ steps.build-info.outputs.sentry-environment }}