|
| 1 | +name: Publish plugin to hub FIPS |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - "plugins-source-test-v*.*.*" |
| 6 | +jobs: |
| 7 | + prepare: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + outputs: |
| 10 | + plugin_name: ${{ steps.split.outputs.plugin_name }} |
| 11 | + plugin_kind: ${{ steps.split.outputs.plugin_kind }} |
| 12 | + plugin_version: ${{ steps.split.outputs.plugin_version }}-fips |
| 13 | + plugin_dir: ${{ steps.split.outputs.plugin_dir }} |
| 14 | + prerelease: ${{ steps.semver_parser.outputs.prerelease }} |
| 15 | + steps: |
| 16 | + - name: Split tag |
| 17 | + id: split |
| 18 | + run: | |
| 19 | + tag=${{ github.ref_name }} |
| 20 | + plugin_kind=$(echo $tag | cut -d- -f2) |
| 21 | + plugin_name=$(echo $tag | cut -d- -f3) |
| 22 | + plugin_version=$(echo $tag | cut -d- -f4-) |
| 23 | + # perform looping till either the plugin version passes our semver test or is empty |
| 24 | + until [[ $plugin_version =~ ^v?[0-9]+\.[0-9]+ ]] || [[ $(echo $plugin_version | wc -c) -eq 0 ]] ; do |
| 25 | + echo "${plugin_version} is not a valid version" |
| 26 | + plugin_name="$plugin_name-$(echo $plugin_version | cut -d- -f1)" |
| 27 | + plugin_version=$(echo $plugin_version | cut -d- -f2-) |
| 28 | + done |
| 29 | + echo "plugin_name=${plugin_name}" >> $GITHUB_OUTPUT |
| 30 | + echo "plugin_kind=${plugin_kind}" >> $GITHUB_OUTPUT |
| 31 | + echo "plugin_version=${plugin_version}" >> $GITHUB_OUTPUT |
| 32 | + echo "plugin_dir=plugins/${plugin_kind}/${plugin_name}" >> $GITHUB_OUTPUT |
| 33 | +
|
| 34 | + # Fail if not a valid SemVer string |
| 35 | + - name: Parse semver string |
| 36 | + uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 |
| 37 | + id: semver_parser |
| 38 | + with: |
| 39 | + input_string: ${{steps.split.outputs.plugin_version}} |
| 40 | + - name: Checkout |
| 41 | + uses: actions/checkout@v4 |
| 42 | + |
| 43 | + publish-plugin-to-hub-fips: |
| 44 | + timeout-minutes: 60 |
| 45 | + runs-on: ubuntu-latest |
| 46 | + container: |
| 47 | + image: ghcr.io/cloudquery/golang-cross:v10.0.0 |
| 48 | + env: |
| 49 | + CC: /usr/bin/gencc.sh |
| 50 | + CXX: /usr/bin/gencpp.sh |
| 51 | + needs: |
| 52 | + - prepare |
| 53 | + steps: |
| 54 | + - name: Checkout |
| 55 | + uses: actions/checkout@v4 |
| 56 | + with: |
| 57 | + fetch-depth: 0 |
| 58 | + |
| 59 | + - uses: actions/cache@v4 |
| 60 | + with: |
| 61 | + path: | |
| 62 | + ~/.cache/go-build |
| 63 | + ~/go/pkg/mod |
| 64 | + key: ${{ runner.os }}-go-1.22.4-publish-plugin-to-hub-fips-cache-${{ hashFiles(format('{0}/{1}', needs.prepare.outputs.plugin_dir, 'go.sum')) }} |
| 65 | + restore-keys: | |
| 66 | + ${{ runner.os }}-go-1.22.4-publish-plugin-to-hub-fips-cache-plugins-${{ needs.prepare.outputs.plugin_kind }}-${{ needs.prepare.outputs.plugin_name }} |
| 67 | +
|
| 68 | + - name: Set up Go 1.x |
| 69 | + uses: actions/setup-go@v5 |
| 70 | + with: |
| 71 | + go-version-file: ${{ needs.prepare.outputs.plugin_dir }}/go.mod |
| 72 | + cache: false |
| 73 | + |
| 74 | + # Needed for shell escape |
| 75 | + - name: Use Node.js LTS |
| 76 | + uses: actions/setup-node@v4 |
| 77 | + with: |
| 78 | + node-version: "lts/*" |
| 79 | + |
| 80 | + - name: Install shell escape |
| 81 | + run: | |
| 82 | + npm install shell-escape@0.2.0 |
| 83 | +
|
| 84 | + - name: Get Release Notes |
| 85 | + id: release-notes |
| 86 | + uses: actions/github-script@v7 |
| 87 | + env: |
| 88 | + PRERELEASE: ${{ needs.prepare.outputs.prerelease }} |
| 89 | + with: |
| 90 | + result-encoding: string |
| 91 | + script: | |
| 92 | + const shellescape = require('shell-escape'); |
| 93 | + const { PRERELEASE } = process.env; |
| 94 | + if (PRERELEASE) { |
| 95 | + return shellescape(["This is a pre-release version of the plugin and should be used for testing purposes only"]) |
| 96 | + } |
| 97 | + const { data } = await github.rest.repos.getReleaseByTag({ |
| 98 | + owner: "cloudquery", |
| 99 | + repo: context.repo.repo, |
| 100 | + tag: context.ref.replace('refs/tags/', ''), |
| 101 | + }); |
| 102 | + return shellescape([data.body]); |
| 103 | +
|
| 104 | + - name: Find and Replace |
| 105 | + uses: jacobtomlinson/gha-find-replace@3a8ed858a4e3fb487c6f53658ec40b2b1d45d9d8 |
| 106 | + with: |
| 107 | + find: "(?i)version_${{ needs.prepare.outputs.plugin_kind }}_${{ needs.prepare.outputs.plugin_name }}" |
| 108 | + replace: ${{ needs.prepare.outputs.plugin_version }} |
| 109 | + include: ${{ needs.prepare.outputs.plugin_dir }}/docs/*.md |
| 110 | + |
| 111 | + - name: Run package command |
| 112 | + working-directory: ${{ needs.prepare.outputs.plugin_dir }} |
| 113 | + env: |
| 114 | + GOEXPERIMENT: "boringcrypto" |
| 115 | + run: | |
| 116 | + rm -rf docs/tables.md |
| 117 | + go run main.go package -m ${{ steps.release-notes.outputs.result }} ${{ needs.prepare.outputs.plugin_version }} . |
| 118 | +
|
| 119 | + - name: Setup CloudQuery |
| 120 | + uses: cloudquery/setup-cloudquery@v4 |
| 121 | + with: |
| 122 | + version: v6.11.2 |
0 commit comments