forked from infracost/infracost
-
Notifications
You must be signed in to change notification settings - Fork 4
130 lines (113 loc) · 3.76 KB
/
create-release.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
name: Upload Release Asset
on:
push:
tags:
- "v*"
jobs:
build:
name: Upload Release Asset
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Build project
run: |
make release
- name: Release
run: go run tools/release/main.go
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Remove build assets
run: rm -rf build
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPOSITORY }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker images
uses: docker/build-push-action@v4
id: build_push_docker
with:
context: .
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tags }}
push: true
- name: Clean Docker image
run: docker rmi ${{ steps.build_push_docker.outputs.imageid }} -f
- name: Docker meta (CI)
id: meta-ci
uses: docker/metadata-action@v5
with:
images: |
${{ secrets.DOCKER_ORG }}/${{ secrets.DOCKER_REPOSITORY }}
flavor: |
prefix=ci-,onlatest=true
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker images (CI)
uses: docker/build-push-action@v4
with:
context: .
file: Dockerfile.ci
platforms: linux/amd64
tags: ${{ steps.meta-ci.outputs.tags }}
push: true
update-homebrew-formula:
if: ${{ !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') }}
name: Update Homebrew formula
needs: build
runs-on: ubuntu-latest
steps:
- name: Install brew
run: |
# Add brew to the path. This is required as brew is no longer supported by runner-images.
# see: https://github.com/actions/runner-images/issues/6283 for more context
echo "/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin" >> $GITHUB_PATH
# Setup brew environment for coming steps.
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
- uses: dawidd6/action-homebrew-bump-formula@v3
with:
token: ${{secrets.HOMEBREW_RELEASE_TOKEN}}
formula: infracost
update-fig-autocomplete-spec:
if: ${{ !contains(github.ref, '-alpha') && !contains(github.ref, '-beta') }}
name: Update Fig autocomplete spec
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Get the new version
id: version
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
- name: Generate the spec
run: |
make build
./build/infracost fig-autocomplete > fig-spec.ts
- name: Create Autocomplete PR
uses: withfig/push-to-fig-autocomplete-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
autocomplete-spec-name: infracost
spec-path: fig-spec.ts
diff-based-versioning: true
new-spec-version: ${{ steps.version.outputs.tag }}
use-minor-base: true