From 34753d6ca31bffe8737807cbfed52aa2c54db27d Mon Sep 17 00:00:00 2001 From: michelsk <120306503+michelsk@users.noreply.github.com> Date: Mon, 8 Jul 2024 10:57:43 +0300 Subject: [PATCH] Steampipe Plugin Akeyless pipeline --- .github/workflows/merge_main.yaml | 31 +++++++++ .github/workflows/release_steampipe.yaml | 85 +++++++++++++++++++++++- .goreleaser.yml | 36 ++++++++++ version | 2 + 4 files changed, 152 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/merge_main.yaml create mode 100644 .goreleaser.yml create mode 100644 version diff --git a/.github/workflows/merge_main.yaml b/.github/workflows/merge_main.yaml new file mode 100644 index 0000000..dc0e85e --- /dev/null +++ b/.github/workflows/merge_main.yaml @@ -0,0 +1,31 @@ +name: Merge Main + +on: + workflow_dispatch: + deployment: + push: + branches: + - main + +jobs: + release: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + token: ${{ secrets.TOKEN_GITHUB }} + + - name: Fetch history + run: git fetch --prune --unshallow + + - name: Configure Git + run: | + git config user.name "$GITHUB_ACTOR" + git config user.email "$GITHUB_ACTOR@users.noreply.github.com" + + - name: Git Tag + run: | + version=$(cat "${GITHUB_WORKSPACE}/version" | sed -n '/v[0-9]\{1,\}.[0-9]\{1,\}.[0-9]\{1,\}/p') + git tag -a $version -m "tagged $version" + git push origin $version \ No newline at end of file diff --git a/.github/workflows/release_steampipe.yaml b/.github/workflows/release_steampipe.yaml index 0ae4a94..5ea7b02 100644 --- a/.github/workflows/release_steampipe.yaml +++ b/.github/workflows/release_steampipe.yaml @@ -1,8 +1,89 @@ name: Release Steampipe Plugin Akeyless + on: workflow_dispatch: + push: + tags: + - 'v*' + +env: + SERVICES_BUCKET_AWS: akeylessservices + jobs: - deploy: + build: + name: Build runs-on: ubuntu-22.04 + permissions: + id-token: write + contents: read steps: - - run: echo "placeholder" + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Set environment variables + run: | + plugin_name=$(echo $GITHUB_REPOSITORY | cut -d'-' -f 3) + echo $plugin_name + echo "PLUGIN_NAME=${plugin_name}" >> $GITHUB_ENV + + - name: Exit if goreleaser file is missing + run: | + test -f .goreleaser.yml + + - name: Set up Go + uses: actions/setup-go@v5 + with: + go-version: 1.22.2 + + - name: Get latest version tag + run: |- + echo "version=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + + - name: Trim tag + run: |- + echo $version + trim=${version#"v"} + echo $trim + echo "version=${trim}" >> $GITHUB_ENV + + - name: Validate Version String + run: |- + if [[ $version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Version is valid: $version" + else + echo "Version is invalid: $version" + exit 1 + fi + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v6 + with: + version: '~> v2' + args: release --clean --skip=publish --timeout=60m + + - name: List Build Artifacts + run: ls -laR ./dist + + - name: Connect to AWS using Github OIDC role + uses: aws-actions/configure-aws-credentials@v4 + with: + role-to-assume: ${{ secrets.AWS_GITHUB_STEAMPIPE_OIDC_ROLE_PRODUCTION }} + aws-region: us-east-2 + + - name: Copy files to AWS S3 bucket + run: | + aws s3 cp ./dist s3://"${SERVICES_BUCKET_AWS}/services/steampipe-plugin-akeyless/release/${version}/" --recursive --exclude "*" --include "*.gz" + + - name: Slack Notification + if: failure() || success() + uses: rtCamp/action-slack-notify@v2 + env: + SLACK_CHANNEL: 'operations' + SLACK_COLOR: ${{ job.status }} + SLACK_TITLE: 'Release Latest Steampipe Plugin Akeyless, Status: ${{ job.status }}!' + SLACK_MESSAGE: 'Version:${{ env.version }}' + SLACK_WEBHOOK: ${{ secrets.SLACK_OPERATIONS_WEBHOOK }} + MSG_MINIMAL: true + SLACK_FOOTER: Akeyless.io Release Steampipe Plugin Akeyless Pipeline diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..8afaf18 --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,36 @@ +version: 2 +before: + hooks: + - go mod tidy +builds: + - env: + - CGO_ENABLED=0 + - GO111MODULE=on + - GOPRIVATE=github.com/akeylesslabs + goos: + - linux + - darwin + + goarch: + - amd64 + - arm64 + + id: "steampipe" + binary: "{{ .ProjectName }}.plugin" + flags: + - -tags=netgo + +archives: + - format: gz + name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" + files: + - none* +checksum: + name_template: "{{ .ProjectName }}_{{ .Version }}_SHA256SUMS" + algorithm: sha256 +changelog: + sort: asc + filters: + exclude: + - "^docs:" + - "^test:" \ No newline at end of file diff --git a/version b/version new file mode 100644 index 0000000..fe9a908 --- /dev/null +++ b/version @@ -0,0 +1,2 @@ +# Use Semantic versioning only. Please update the version number before opening a pull request. +v0.0.0 \ No newline at end of file