forked from cloudquery/cloudquery
-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (175 loc) · 8.23 KB
/
Copy pathrelease_plugin.yml
File metadata and controls
187 lines (175 loc) · 8.23 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: release-plugin
on:
push:
tags:
- "plugins-*-*-v*.*.*"
- "!plugins-destination-duckdb-v*.*.*"
- "!plugins-destination-sqlite-v*.*.*"
- "!plugins-destination-snowflake-v*.*.*"
- "!plugins-source-test-v*.*.*"
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
plugin_name: ${{ steps.split.outputs.plugin_name }}
plugin_type: ${{ steps.split.outputs.plugin_type }}
plugin_version: ${{ steps.split.outputs.plugin_version }}
plugin_dir: ${{ steps.split.outputs.plugin_dir }}
prerelease: ${{ steps.semver_parser.outputs.prerelease }}
plugin_releaser: ${{ steps.set-result.outputs.result }}
steps:
- name: Split tag
id: split
run: |
tag=${{ github.ref_name }}
plugin_type=$(echo $tag | cut -d- -f2)
plugin_name=$(echo $tag | cut -d- -f3)
plugin_version=$(echo $tag | cut -d- -f4-)
echo "plugin_name=${plugin_name}" >> $GITHUB_OUTPUT
echo "plugin_type=${plugin_type}" >> $GITHUB_OUTPUT
echo "plugin_version=${plugin_version}" >> $GITHUB_OUTPUT
echo "plugin_dir=plugins/${plugin_type}/${plugin_name}" >> $GITHUB_OUTPUT
# Fail if not a valid SemVer string
- name: Parse semver string
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3
id: semver_parser
with:
input_string: ${{steps.split.outputs.plugin_version}}
- name: Checkout
uses: actions/checkout@v3
- uses: actions/github-script@v6
id: set-result
env:
PLUGIN_DIR: ${{steps.split.outputs.plugin_dir}}
with:
script: |
const fs = require('fs').promises;
const path = require('path');
const pluginFiles = await fs.readdir(process.env.PLUGIN_DIR);
if (pluginFiles.includes('Dockerfile')) {
return 'docker';
}
if (pluginFiles.includes('.goreleaser.yaml')) {
return 'go';
}
result-encoding: string
release-plugin-docker:
permissions:
contents: read
packages: write
timeout-minutes: 60
runs-on: large-ubuntu-monorepo
needs: prepare
if: needs.prepare.outputs.plugin_releaser == 'docker'
env:
IMAGE_NAME_PREFIX: cloudquery
REGISTRY: ghcr.io
steps:
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@4c0219f9ac95b02789c1075625400b2acbff50b1
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PREFIX }}/cq-${{ needs.prepare.outputs.plugin_type }}-${{ needs.prepare.outputs.plugin_name }}
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
env:
BUILDX_NO_DEFAULT_ATTESTATIONS: 1
with:
context: "{{defaultContext}}:${{ needs.prepare.outputs.plugin_dir }}"
platforms: linux/amd64,linux/arm64
push: true
tags: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PREFIX }}/cq-${{ needs.prepare.outputs.plugin_type }}-${{ needs.prepare.outputs.plugin_name }}:latest
${{ env.REGISTRY }}/${{ env.IMAGE_NAME_PREFIX }}/cq-${{ needs.prepare.outputs.plugin_type }}-${{ needs.prepare.outputs.plugin_name }}:${{ needs.prepare.outputs.plugin_version }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Checkout
uses: actions/checkout@v3
- name: Update version file
if: needs.prepare.outputs.prerelease == ''
run: 'echo "{ \"latest\": \"${{github.ref_name}}\" }" > ./website/versions/${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}.json'
- name: Create Pull Request
if: needs.prepare.outputs.prerelease == ''
uses: peter-evans/create-pull-request@v4
with:
# required so the PR triggers workflow runs
token: ${{ secrets.GH_CQ_BOT }}
branch: chore/update-plugin-${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}-version
base: main
title: "chore: Update plugin `${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}` version to ${{needs.prepare.outputs.plugin_version}}"
commit-message: "chore: Update plugin `${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}` version to ${{needs.prepare.outputs.plugin_version}}"
body: Updates the `${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}` plugin latest version to ${{needs.prepare.outputs.plugin_version}}
labels: automerge
author: cq-bot <cq-bot@users.noreply.github.com>
release-plugin-go:
timeout-minutes: 60
runs-on: large-ubuntu-monorepo
needs: prepare
if: needs.prepare.outputs.plugin_releaser == 'go'
env:
CGO_ENABLED: 0
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-1.20.5-release-cache-${{ hashFiles(format('{0}/{1}', needs.prepare.outputs.plugin_dir, 'go.sum')) }}
restore-keys: |
${{ runner.os }}-go-1.20.5-release-cache-plugins-${{ needs.prepare.outputs.plugin_type }}-${{ needs.prepare.outputs.plugin_name }}
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version-file: ${{needs.prepare.outputs.plugin_dir}}/go.mod
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@v3
with:
distribution: goreleaser-pro
version: latest
install-only: true
- name: Run GoReleaser Dry-Run
run: goreleaser release --timeout 50m --clean --skip-validate --skip-publish --skip-sign -f ./${{needs.prepare.outputs.plugin_dir}}/.goreleaser.yaml
env:
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.PRIVATE_KEY }}
- name: Run GoReleaser
run: goreleaser release --timeout 50m --clean -f ./${{needs.prepare.outputs.plugin_dir}}/.goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GORELEASER_KEY: ${{ secrets.GORELEASER_KEY }}
GORELEASER_CURRENT_TAG: ${{ github.ref_name }}
- name: Update version file
if: needs.prepare.outputs.prerelease == ''
run: 'echo "{ \"latest\": \"${{github.ref_name}}\" }" > ./website/versions/${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}.json'
- name: Create Pull Request
if: needs.prepare.outputs.prerelease == ''
uses: peter-evans/create-pull-request@v4
with:
# required so the PR triggers workflow runs
token: ${{ secrets.GH_CQ_BOT }}
branch: chore/update-plugin-${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}-version
base: main
title: "chore: Update plugin `${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}` version to ${{needs.prepare.outputs.plugin_version}}"
commit-message: "chore: Update plugin `${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}` version to ${{needs.prepare.outputs.plugin_version}}"
body: Updates the `${{needs.prepare.outputs.plugin_type}}-${{needs.prepare.outputs.plugin_name}}` plugin latest version to ${{needs.prepare.outputs.plugin_version}}
labels: automerge
author: cq-bot <cq-bot@users.noreply.github.com>