-
Notifications
You must be signed in to change notification settings - Fork 39
139 lines (137 loc) · 6.14 KB
/
Copy pathrelease.yml
File metadata and controls
139 lines (137 loc) · 6.14 KB
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
name: Release
on:
push:
branches:
- main
workflow_dispatch:
inputs:
is_draft:
description: 'Is this a draft release?'
required: false
type: boolean
default: false
pre_release:
description: 'Is this a pre-release?'
required: false
type: boolean
default: false
permissions:
contents: write
packages: write
jobs:
release:
name: Release
runs-on:
group: windows-latest-large
if: startsWith(github.event.head_commit.message, 'ci:') != true
outputs:
tag: ${{ steps.changelog.outputs.tag }}
steps:
- name: Setup environment
run: |-
chcp 65001 #set code page to utf-8
echo ("GOPRIVATE=github.com/speakeasy-api") >> $env:GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Conventional Commits
id: changelog
uses: TriPSs/conventional-changelog-action@91be4f3188da74fe85de9caffcebc80b26d43b5b # v6.3.0
with:
github-token: ${{ secrets.github_token }}
skip-commit: "true"
output-file: "false"
skip-on-empty: "false"
preset: conventionalcommits
pre-release: ${{ inputs.pre_release == true && 'true' || 'false' }}
- uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0
with:
go-version-file: "go.mod"
# Reference: https://github.com/actions/setup-go/issues/495
cache: false
# More assembly might be required: Docker logins, GPG, etc. It all depends
# on your needs.
- name: Configure git for private modules
run: git config --global url."https://speakeasybot:${{ secrets.BOT_REPO_TOKEN }}@github.com".insteadOf "https://github.com"
- name: Setup Choco
uses: crazy-max/ghaction-chocolatey@2526f467ccbd337d307fe179959cabbeca0bc8c0 # v3.4.0
with:
args: --version
- name: goreleaser
uses: goreleaser/goreleaser-action@e435ccd777264be153ace6237001ef4d979d3a7a # v6.4.0
with:
distribution: goreleaser
version: latest
args: release --clean ${{ inputs.is_draft == true && '--draft' || '' }} ${{ vars.SKIP_CHOCOLATEY == 'true' && '--skip=chocolatey' || '' }} ${{ inputs.pre_release == true && '--skip=homebrew,chocolatey,winget' || '' }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_REPO_TOKEN }}
CHOCOLATEY_API_KEY: ${{ secrets.CHOCOLATEY_API_KEY }}
IS_DRAFT: ${{ inputs.is_draft }}
- name: Upload dist artifacts for docker build
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
with:
name: dist
path: dist/
retention-days: 1
docker:
name: Build Docker Images
runs-on:
group: ubuntu-latest-large
needs: release
if: needs.release.outputs.tag != ''
env:
REGISTRY: ghcr.io
IMAGE_NAME: speakeasy-api/speakeasy
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
- name: Download dist artifacts
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
with:
name: dist
path: dist/
- name: Organize binaries for Docker build
run: |
mkdir -p linux/amd64 linux/arm64
cp dist/speakeasy_linux_amd64_v1/speakeasy linux/amd64/speakeasy
cp dist/speakeasy_linux_arm64_v8.0/speakeasy linux/arm64/speakeasy
chmod +x linux/amd64/speakeasy linux/arm64/speakeasy
- name: Set up QEMU
uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
- name: Login to GitHub Container Registry
uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{raw}},value=${{ needs.release.outputs.tag }}
type=raw,value=latest
- name: Build and push Docker image
uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 # v6.18.0
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ inputs.is_draft != true }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
reconcile:
name: Trigger Changelog Reconcile
runs-on: ubuntu-latest
needs: docker
if: needs.docker.result == 'success' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.is_draft == false))
steps:
- name: Trigger changelog reconcile
run: gh workflow run changelog-reconcile.yml --repo speakeasy-api/marketing-site --ref main
env:
GH_TOKEN: ${{ secrets.BOT_REPO_TOKEN }}