-
Notifications
You must be signed in to change notification settings - Fork 350
156 lines (140 loc) · 5.13 KB
/
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Release
on:
workflow_dispatch:
inputs:
version:
description: 'Version to build ("1.2.3")'
required: true
encorego_version:
description: 'Encore-Go version to use ("encore-go1.17.7")'
required: true
jobs:
build:
strategy:
matrix:
include:
- builder: ubuntu-20.04
goos: linux
goarch: amd64
release_key: linux_x86-64
- builder: ubuntu-20.04
goos: linux
goarch: arm64
release_key: linux_arm64
- builder: macos-11
goos: darwin
goarch: amd64
release_key: macos_x86-64
- builder: macos-11
goos: darwin
goarch: arm64
release_key: macos_arm64
- builder: windows-latest
goos: windows
goarch: amd64
release_key: windows_x86-64
runs-on: ${{ matrix.builder }}
steps:
- name: Check out repo
uses: actions/checkout@v3
with:
path: encr.dev
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version-file: 'encr.dev/go.mod'
check-latest: true
cache-dependency-path: 'encr.dev/go.sum'
- name: Set up Zig
uses: goto-bus-stop/setup-zig@v1
with:
version: 0.10.1
- name: Install encore-go
run: curl --fail -o encore-go.tar.gz -L https://github.com/encoredev/go/releases/download/${{ github.event.inputs.encorego_version }}/${{ matrix.release_key }}.tar.gz && tar -C ${{ github.workspace }} -xzf ./encore-go.tar.gz
- name: Build
run: cd encr.dev && go run ./pkg/make-release/make-release.go -v="${{ github.event.inputs.version }}" -dst=dist -goos=${{ matrix.goos }} -goarch=${{ matrix.goarch }} -encore-go="../encore-go"
env:
GO111MODULE: "on"
if: runner.os != 'windows'
- name: Build
run: cd encr.dev && .\pkg\make-release\windows\build.bat
env:
GO111MODULE: "on"
ENCORE_VERSION: "${{ github.event.inputs.version }}"
ENCORE_GOROOT: "../encore-go"
if: runner.os == 'windows'
- name: 'Tar artifacts'
run: tar -czvf encore-${{ github.event.inputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz -C encr.dev/dist/${{ matrix.goos }}_${{ matrix.goarch }} .
- name: Publish artifact
uses: actions/upload-artifact@v3
with:
name: encore-${{ github.event.inputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }}
path: encore-${{ github.event.inputs.version }}-${{ matrix.goos }}_${{ matrix.goarch }}.tar.gz
publish-docker-images:
name: "publish docker images"
runs-on: ubuntu-20.04
needs: build
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v3
with:
sparse-checkout: .github
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: .github/dockerimg/artifacts
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to Docker Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: encoredotdev/encore
labels: |
org.opencontainers.image.title=Encore
org.opencontainers.image.vendor=encore.dev
org.opencontainers.image.authors=support@encore.dev
org.opencontainers.image.description=Encore is the end-to-end Backend Development Platform that lets you escape cloud complexity.
tags: |
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=semver,pattern={{version}},value=v${{ github.event.inputs.version }}
type=semver,pattern={{major}}.{{minor}},value=v${{ github.event.inputs.version }}
type=semver,pattern={{major}},value=v${{ github.event.inputs.version }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: .github/dockerimg
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
RELEASE_VERSION=${{ github.event.inputs.version }}
notify_release_success:
needs:
- build
- publish-docker-images
runs-on: ubuntu-20.04
steps:
- name: Webhook
uses: distributhor/workflow-webhook@v3
env:
webhook_type: 'json'
webhook_url: ${{ secrets.RELEASE_WEBHOOK }}
data: '{ "version": "${{ github.event.inputs.version }}", "run_id": "${{ github.run_id }}" }'