forked from cloudquery/cloudquery
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (88 loc) · 4.05 KB
/
Copy pathrelease_plugin.yml
File metadata and controls
91 lines (88 loc) · 4.05 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
name: release-plugin
on:
push:
tags:
- "plugins-*-*-v*.*.*"
- "!plugins-destination-duckdb-v*.*.*"
- "!plugins-destination-sqlite-v*.*.*"
- "!plugins-destination-snowflake-v*.*.*"
env:
CGO_ENABLED: 0
jobs:
release-plugin-binary:
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
# Tag format is plugins-<type>-<name>-<version>
- 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 "plugins_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
with:
fetch-depth: 2
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-1.19.5-release-cache-${{ hashFiles(format('{0}/{1}', steps.split.outputs.plugins_dir, 'go.sum')) }}
restore-keys: |
${{ runner.os }}-go-1.19.5-release-cache-plugins-${{ steps.split.outputs.plugin_type }}-${{ steps.split.outputs.plugin_name }}
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version-file: ${{steps.split.outputs.plugins_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 ./${{steps.split.outputs.plugins_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 ./${{steps.split.outputs.plugins_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: steps.semver_parser.outputs.prerelease == ''
run: 'echo "{ \"latest\": \"${{github.ref_name}}\" }" > ./website/versions/${{steps.split.outputs.plugin_type}}-${{steps.split.outputs.plugin_name}}.json'
- name: Create Pull Request
if: steps.semver_parser.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-${{steps.split.outputs.plugin_type}}-${{steps.split.outputs.plugin_name}}-version
base: main
title: "chore: Update plugin `${{steps.split.outputs.plugin_type}}-${{steps.split.outputs.plugin_name}}` version to ${{steps.split.outputs.plugin_version}}"
commit-message: "chore: Update plugin `${{steps.split.outputs.plugin_type}}-${{steps.split.outputs.plugin_name}}` version to ${{steps.split.outputs.plugin_version}}"
body: Updates the `${{steps.split.outputs.plugin_type}}-${{steps.split.outputs.plugin_name}}` plugin latest version to ${{steps.split.outputs.plugin_version}}
labels: automerge
author: cq-bot <cq-bot@users.noreply.github.com>