Skip to content

Commit

Permalink
ci: CQ Hub release
Browse files Browse the repository at this point in the history
0537e9eda11423dacc0046ac721e36ad3080b012
  • Loading branch information
kabachook committed Feb 22, 2024
1 parent cecd203 commit a3d248f
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 12 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/release-hub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Release plugin to CloudQuery Hub

on:
push:
tags:
- "v*"

jobs:
release-hub:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-deep: 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@v4

- 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 }} ${{ 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
12 changes: 8 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,27 @@ name: Release plugin to GitHub
on:
push:
tags:
- "*"
- "v*"

jobs:
release:
timeout-minutes: 60
runs-on: ubuntu-latest
env:
CGO_ENABLED: 0
permissions:
contents: read
packages: write
timeout-minutes: 60
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-deep: 0

- name: Setup Go 1.x
uses: actions/setup-go@v4
- name: Install GoReleaser

- name: Install GoReleaser & publish
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
Expand Down
5 changes: 4 additions & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,7 @@ changelog:
filters:
exclude:
- "^docs:"
- "^test:"
- "^test:"

release:
prerelease: auto
2 changes: 2 additions & 0 deletions .mapping.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
".":"security/cloudquery/github_toplevel/cq-source-yc",
".github/workflows/release-hub.yml":"security/cloudquery/github_toplevel/cq-source-yc/.github/workflows/release-hub.yml",
".github/workflows/release.yml":"security/cloudquery/github_toplevel/cq-source-yc/.github/workflows/release.yml",
".gitignore":"security/cloudquery/cq-source-yc/.gitignore",
".goreleaser.yaml":"security/cloudquery/github_toplevel/cq-source-yc/.goreleaser.yaml",
Expand Down Expand Up @@ -180,6 +181,7 @@
"resources/vpc/security_groups.go":"security/cloudquery/cq-source-yc/resources/vpc/security_groups.go",
"resources/vpc/subnets.go":"security/cloudquery/cq-source-yc/resources/vpc/subnets.go",
"resources/ydb/databases.go":"security/cloudquery/cq-source-yc/resources/ydb/databases.go",
"security/cloudquery/github_toplevel/cq-source-yc/.github/workflows/release-hub.yml":"security/cloudquery/github_toplevel/cq-source-yc/.github/workflows/release-hub.yml",
"security/cloudquery/github_toplevel/cq-source-yc/.github/workflows/release.yml":"security/cloudquery/github_toplevel/cq-source-yc/.github/workflows/release.yml",
"security/cloudquery/github_toplevel/cq-source-yc/.goreleaser.yaml":"security/cloudquery/github_toplevel/cq-source-yc/.goreleaser.yaml",
"security/cloudquery/github_toplevel/cq-source-yc/AUTHORS":"security/cloudquery/github_toplevel/cq-source-yc/AUTHORS",
Expand Down
15 changes: 8 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ test:

.PHONY: build
build:
go build -o cq-source-yc main.go

.PHONY: lint
lint:
@golangci-lint run --timeout 10m
go build -o yc main.go

.PHONY: gen-docs
gen-docs:
gen-docs: build
# TODO: replace with cloudquery cli invocation
rm -rf ./docs/tables/*
go run main.go doc ./docs/tables

.PHONY: lint
lint:
@golangci-lint run --timeout 10m

# All gen targets
.PHONY: gen
gen: gen-docs
Expand All @@ -24,4 +25,4 @@ gen: gen-docs

.PHONY: start-source
start-source: build
./cq-source-yc serve --log-level debug
./yc serve --log-level debug

0 comments on commit a3d248f

Please sign in to comment.