-
Notifications
You must be signed in to change notification settings - Fork 12
127 lines (113 loc) · 3.67 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
name: Release plugin
on:
push:
tags:
- "v*"
jobs:
release-gh:
name: Publish to Github Releases
timeout-minutes: 60
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Install GoReleaser & publish
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-hub:
name: Publish to CloudQuery Hub
needs: [release-gh]
timeout-minutes: 60
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js LTS
uses: actions/setup-node@v4
with:
node-version: 'lts/*'
- name: Install dependencies from npm
run: npm i semver@^7.6
- name: Setup Go 1.x
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Setup CloudQuery
uses: cloudquery/setup-cloudquery@v3
with:
version: v5.5.6
- name: Parse and validate semver tag
id: semver-tag
uses: actions/github-script@v7
with:
script: |
const semverParse = require("semver/functions/parse");
const input = context.ref.replace('refs/tags/', '');
const version = semverParse(input);
if (!version) {
throw new Error("invalid semver string")
}
core.setOutput("raw", version.raw);
core.setOutput("version", version.version);
core.setOutput("major", version.major);
core.setOutput("minor", version.minor);
core.setOutput("patch", version.path);
core.setOutput("prerelease", version.prerelease.join("."));
core.setOutput("build", version.build.join("."));
- name: Get Release Notes
id: release-notes
uses: actions/github-script@v7
env:
PRERELEASE: ${{ steps.semver-tag.outputs.prerelease }}
with:
result-encoding: string
retries: 3
script: |
const fs = require('node:fs');
const FILENAME = "message.txt";
const { PRERELEASE } = process.env;
let message;
if (PRERELEASE) {
message = "This is a pre-release version of the plugin and should be used for testing purposes only";
} else {
const { data } = await github.rest.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: context.ref.replace('refs/tags/', ''),
});
message = data;
}
fs.writeFileSync(FILENAME, message);
return `@${FILENAME}`; // @ is for cloudquery cli to read from file
- name: Run package command
run: |
go run main.go package -m ${{ steps.release-notes.outputs.result }} v${{ steps.semver-tag.outputs.version }} .
- name: Publish plugin to hub
env:
CLOUDQUERY_API_KEY: ${{ secrets.CLOUDQUERY_API_KEY }}
PRERELEASE: ${{ steps.semver-tag.outputs.prerelease }}
run: |
if [[ -z $PRERELEASE ]]; then
cloudquery plugin publish --finalize
else
cloudquery plugin publish
fi