-
Notifications
You must be signed in to change notification settings - Fork 500
118 lines (110 loc) · 4.47 KB
/
publish_plugin_to_hub_snowflake.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
name: Publish plugin to Snowflake to hub
on:
push:
tags:
- "plugins-destination-snowflake-v*.*.*"
jobs:
prepare:
runs-on: ubuntu-latest
outputs:
plugin_name: ${{ steps.split.outputs.plugin_name }}
plugin_kind: ${{ steps.split.outputs.plugin_kind }}
plugin_kind_plural: ${{ steps.split.outputs.plugin_kind_plural }}
plugin_version: ${{ steps.split.outputs.plugin_version }}
plugin_dir: ${{ steps.split.outputs.plugin_dir }}
prerelease: ${{ steps.semver_parser.outputs.prerelease }}
steps:
- name: Split tag
id: split
run: |
tag=${{ github.ref_name }}
plugin_kind=$(echo $tag | cut -d- -f2)
plugin_name=$(echo $tag | cut -d- -f3)
plugin_kind_plural=$(if [ "$plugin_kind" = "source" ]; then echo "sources"; else echo "destinations"; fi)
plugin_version=$(echo $tag | cut -d- -f4-)
echo "plugin_name=${plugin_name}" >> $GITHUB_OUTPUT
echo "plugin_kind=${plugin_kind}" >> $GITHUB_OUTPUT
echo "plugin_kind_plural=${plugin_kind_plural}" >> $GITHUB_OUTPUT
echo "plugin_version=${plugin_version}" >> $GITHUB_OUTPUT
echo "plugin_dir=plugins/${plugin_kind}/${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}}
publish-plugin-to-hub:
timeout-minutes: 60
runs-on: large-ubuntu-monorepo
container:
image: ghcr.io/cloudquery/golang-cross:v10.0.0
env:
CGO_ENABLED: 1
CC: /usr/bin/gencc.sh
CXX: /usr/bin/gencpp.sh
GOAMD64: v1
needs: prepare
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-1.21.1-publish-plugin-to-hub-cache-${{ hashFiles(format('{0}/{1}', needs.prepare.outputs.plugin_dir, 'go.sum')) }}
restore-keys: |
${{ runner.os }}-go-1.21.1-publish-plugin-to-hub-cache-plugins-${{ needs.prepare.outputs.plugin_kind }}-${{ needs.prepare.outputs.plugin_name }}
- name: Set up Go 1.x
uses: actions/setup-go@v4
with:
go-version-file: ${{ needs.prepare.outputs.plugin_dir }}/go.mod
cache: false
- name: Use Node.js LTS
uses: actions/setup-node@v3
with:
node-version: 'lts/*'
- name: Install shell escape
run: |
npm install shell-escape@0.2.0
- name: Get Release Notes
id: release-notes
uses: actions/github-script@v6
env:
PRERELEASE: ${{ needs.prepare.outputs.prerelease }}
with:
result-encoding: string
script: |
const shellescape = require('shell-escape');
const { PRERELEASE } = process.env;
if (PRERELEASE) {
return shellescape(["This is a pre-release version of the plugin and should be used for testing purposes only"])
}
const { data } = await github.rest.repos.getReleaseByTag({
owner: "cloudquery",
repo: context.repo.repo,
tag: context.ref.replace('refs/tags/', ''),
});
return shellescape([data.body]);
- name: Find and Replace
uses: jacobtomlinson/gha-find-replace@3a8ed858a4e3fb487c6f53658ec40b2b1d45d9d8
with:
find: "(?i)version_${{ needs.prepare.outputs.plugin_kind }}_${{ needs.prepare.outputs.plugin_name }}"
replace: ${{ needs.prepare.outputs.plugin_version }}
include: ${{ needs.prepare.outputs.plugin_dir }}/docs/*.md
- name: Run package command
working-directory: ${{ needs.prepare.outputs.plugin_dir }}
run: |
go run main.go package -m ${{ steps.release-notes.outputs.result }} ${{ needs.prepare.outputs.plugin_version }} .
- name: Setup CloudQuery
uses: cloudquery/setup-cloudquery@v3
with:
version: v4.3.6
- name: Publish plugin to hub
working-directory: ${{ needs.prepare.outputs.plugin_dir }}
run: |
mkdir -p ~/.local/share/cloudquery
echo ${{ secrets.CQ_CI_CLOUDQUERY_HUB_TOKEN }} > ~/.local/share/cloudquery/token
cloudquery plugin publish --finalize