mirror of
https://github.com/turbot/steampipe.git
synced 2025-12-19 09:58:53 -05:00
Merge branch 'v2.0.x' into develop
This commit is contained in:
249
.github/workflows/01-steampipe-release.yaml
vendored
Normal file
249
.github/workflows/01-steampipe-release.yaml
vendored
Normal file
@@ -0,0 +1,249 @@
|
||||
name: "01 - Steampipe: Release"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
environment:
|
||||
type: choice
|
||||
description: "Select Release Type"
|
||||
options:
|
||||
# to change the values in this option, we also need to update the condition test below in at least 3 location. Search for github.event.inputs.environment
|
||||
- Development (alpha)
|
||||
- Development (beta)
|
||||
- Final (RC and final release)
|
||||
required: true
|
||||
version:
|
||||
description: "Version (without 'v')"
|
||||
required: true
|
||||
default: 0.2.\invalid
|
||||
confirmDevelop:
|
||||
description: Confirm running on develop branch
|
||||
required: true
|
||||
type: boolean
|
||||
|
||||
env:
|
||||
# Version number from user input, used throughout the workflow for tagging, branching, and release operations
|
||||
VERSION: ${{ github.event.inputs.version }}
|
||||
# GitHub personal access token for authenticated API operations like creating releases, managing PRs, and repository access
|
||||
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
# PostgreSQL connection string used in acceptance tests (tests/acceptance/test_files/cloud.bats)
|
||||
SPIPETOOLS_PG_CONN_STRING: ${{ secrets.SPIPETOOLS_PG_CONN_STRING }}
|
||||
# Authentication token for Steampipe Cloud services used in acceptance tests (tests/acceptance/test_files/cloud.bats and snapshot.bats)
|
||||
SPIPETOOLS_TOKEN: ${{ secrets.SPIPETOOLS_TOKEN }}
|
||||
# Disable update checks during CI runs to avoid unnecessary network calls and delays
|
||||
STEAMPIPE_UPDATE_CHECK: false
|
||||
|
||||
jobs:
|
||||
ensure_branch_in_homebrew:
|
||||
name: Ensure branch exists in homebrew-tap
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Calculate version
|
||||
id: calculate_version
|
||||
run: |
|
||||
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Parse semver string
|
||||
id: semver_parser
|
||||
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
|
||||
with:
|
||||
input_string: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Checkout
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: main
|
||||
|
||||
- name: Delete base branch if exists
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
git fetch --all
|
||||
git push origin --delete bump-brew
|
||||
git push origin --delete $VERSION
|
||||
continue-on-error: true
|
||||
|
||||
- name: Create base branch
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
git checkout -b bump-brew
|
||||
git push --set-upstream origin bump-brew
|
||||
|
||||
build_and_release_cli:
|
||||
name: Release CLI
|
||||
needs: [ensure_branch_in_homebrew]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: steampipe
|
||||
ref: ${{ github.event.ref }}
|
||||
|
||||
- name: Checkout Pipe Fittings Components repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/pipe-fittings
|
||||
path: pipe-fittings
|
||||
ref: v1.6.x
|
||||
|
||||
- name: Calculate version
|
||||
id: calculate_version
|
||||
run: |
|
||||
if [ "${{ github.event.inputs.environment }}" = "Development (alpha)" ]; then
|
||||
echo "VERSION=v${{ github.event.inputs.version }}-alpha.$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
|
||||
elif [ "${{ github.event.inputs.environment }}" = "Development (beta)" ]; then
|
||||
echo "VERSION=v${{ github.event.inputs.version }}-beta.$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV
|
||||
else
|
||||
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
- name: Tag Release
|
||||
run: |
|
||||
cd steampipe
|
||||
git config user.name "Steampipe GitHub Actions Bot"
|
||||
git config user.email noreply@github.com
|
||||
git tag $VERSION
|
||||
git push origin $VERSION
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
||||
with:
|
||||
go-version: 1.23
|
||||
|
||||
- name: Install GoReleaser
|
||||
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
|
||||
with:
|
||||
install-only: true
|
||||
|
||||
- name: Run GoReleaser
|
||||
run: |
|
||||
cd steampipe
|
||||
goreleaser release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
|
||||
create_pr_in_homebrew:
|
||||
name: Create PR in homebrew-tap
|
||||
if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }}
|
||||
needs: [ensure_branch_in_homebrew, build_and_release_cli]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Version: ${{ github.event.inputs.version }}
|
||||
steps:
|
||||
- name: Calculate version
|
||||
id: calculate_version
|
||||
run: |
|
||||
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Parse semver string
|
||||
id: semver_parser
|
||||
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
|
||||
with:
|
||||
input_string: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Checkout
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: main
|
||||
|
||||
- name: Create a new branch off the base branch
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
git fetch --all
|
||||
git checkout bump-brew
|
||||
git checkout -b $VERSION
|
||||
git push --set-upstream origin $VERSION
|
||||
|
||||
- name: Close pull request if already exists
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
gh pr close $VERSION
|
||||
continue-on-error: true
|
||||
|
||||
- name: Create pull request
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
gh pr create --base main --head $VERSION --title "Steampipe $Version" --body "Update formula"
|
||||
|
||||
update_pr_for_versioning:
|
||||
name: Update PR
|
||||
if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }}
|
||||
needs: [create_pr_in_homebrew]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Version: ${{ github.event.inputs.version }}
|
||||
steps:
|
||||
- name: Calculate version
|
||||
id: calculate_version
|
||||
run: |
|
||||
echo "VERSION=v${{ github.event.inputs.version }}" >> $GITHUB_ENV
|
||||
|
||||
- name: Parse semver string
|
||||
id: semver_parser
|
||||
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
|
||||
with:
|
||||
input_string: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Checkout
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Update live version
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
scripts/formula_versioning.sh
|
||||
git config --global user.email "puskar@turbot.com"
|
||||
git config --global user.name "Puskar Basu"
|
||||
git add .
|
||||
git commit -m "Versioning brew formulas"
|
||||
git push origin $VERSION
|
||||
|
||||
update_homebrew_tap:
|
||||
name: Update homebrew-tap formula
|
||||
if: ${{ github.event.inputs.environment == 'Final (RC and final release)' }}
|
||||
needs: update_pr_for_versioning
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: main
|
||||
|
||||
- name: Get pull request title
|
||||
id: pr_title
|
||||
run: >-
|
||||
echo "PR_TITLE=$(
|
||||
gh pr view $VERSION --json title | jq .title | tr -d '"'
|
||||
)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Output
|
||||
run: |
|
||||
echo ${{ steps.pr_title.outputs.PR_TITLE }}
|
||||
echo ${{ env.VERSION }}
|
||||
|
||||
- name: Fail if PR title does not match with version
|
||||
run: |
|
||||
if [[ "${{ steps.pr_title.outputs.PR_TITLE }}" == "Steampipe ${{ env.VERSION }}" ]]; then
|
||||
echo "Correct version"
|
||||
else
|
||||
echo "Incorrect version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Merge pull request to update brew formula
|
||||
run: |
|
||||
git fetch --all
|
||||
gh pr merge $VERSION --squash --delete-branch
|
||||
git push origin --delete bump-brew
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Build and Publish DB Image
|
||||
name: "02 - Steampipe: Build and Publish DB Image"
|
||||
|
||||
# Controls when the action will run.
|
||||
on:
|
||||
41
.github/workflows/10-test-lint.yaml
vendored
Normal file
41
.github/workflows/10-test-lint.yaml
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
name: "10 - Test: Linting"
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- v*
|
||||
branches:
|
||||
- main
|
||||
- "v*"
|
||||
workflow_dispatch:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
golangci:
|
||||
name: Test Linting
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: steampipe
|
||||
|
||||
- name: Checkout Pipe Fittings Components repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/pipe-fittings
|
||||
path: pipe-fittings
|
||||
ref: v1.6.x
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
||||
with:
|
||||
go-version: 1.22
|
||||
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
||||
continue-on-error: true # we dont want to enforce just yet
|
||||
with:
|
||||
version: v1.52.2
|
||||
args: --timeout=15m --config=.golangci.yml
|
||||
skip-pkg-cache: true
|
||||
skip-build-cache: true
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Steampipe Acceptance Tests
|
||||
name: "11 - Test: Acceptance"
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
@@ -45,16 +45,6 @@ jobs:
|
||||
path: ${{ steps.go-cache-paths.outputs.go-build }}
|
||||
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
|
||||
|
||||
# TODO fix this step (cant find the path to golangci.yml)
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@4afd733a84b1f43292c63897423277bb7f4313a9 # v8.0.0
|
||||
continue-on-error: true # we dont want to enforce just yet
|
||||
with:
|
||||
version: v1.52.2
|
||||
args: --timeout=15m --config=.golangci.yml
|
||||
skip-pkg-cache: true
|
||||
skip-build-cache: true
|
||||
|
||||
- name: Run CLI Unit Tests
|
||||
run: |
|
||||
cd steampipe
|
||||
@@ -1,4 +1,4 @@
|
||||
name: Stale Issues and PRs
|
||||
name: "30 - Admin: Stale Issues and PRs"
|
||||
on:
|
||||
schedule:
|
||||
- cron: "0 8 * * *"
|
||||
51
.github/workflows/publish_brew.yml
vendored
51
.github/workflows/publish_brew.yml
vendored
@@ -1,51 +0,0 @@
|
||||
name: Publish and Update Brew
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release:
|
||||
description: "The name of the released version to publish"
|
||||
required: true
|
||||
|
||||
env:
|
||||
STEAMPIPE_VERSION: ${{ github.event.inputs.release }}
|
||||
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
|
||||
jobs:
|
||||
|
||||
update_homebrew_tap:
|
||||
name: Update homebrew-tap formula
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: main
|
||||
|
||||
- name: Get pull request title
|
||||
id: pr_title
|
||||
run: >-
|
||||
echo "PR_TITLE=$(
|
||||
gh pr view $STEAMPIPE_VERSION --json title | jq .title | tr -d '"'
|
||||
)" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Output
|
||||
run: |
|
||||
echo ${{ steps.pr_title.outputs.PR_TITLE }}
|
||||
echo ${{ env.STEAMPIPE_VERSION }}
|
||||
|
||||
- name: Fail if PR title does not match with version
|
||||
run: |
|
||||
if ${{ (steps.pr_title.outputs.PR_TITLE == env.STEAMPIPE_VERSION) }} == 'true';then
|
||||
echo "Correct version"
|
||||
else
|
||||
echo "Incorrect version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Merge pull request to update brew formula
|
||||
run: |
|
||||
git fetch --all
|
||||
gh pr merge $STEAMPIPE_VERSION --squash --delete-branch
|
||||
git push origin --delete bump-brew
|
||||
674
.github/workflows/release_cli_and_assets.yml
vendored
674
.github/workflows/release_cli_and_assets.yml
vendored
@@ -1,674 +0,0 @@
|
||||
name: Steampipe CLI Release
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
version:
|
||||
description: "The version to release (must be prefixed with 'v')"
|
||||
required: true
|
||||
|
||||
env:
|
||||
PROJECT_ID: steampipe
|
||||
CORE_REPO: us-docker.pkg.dev/steampipe/steampipe
|
||||
ORG: turbot
|
||||
ASSET_IMAGE_NAME: assets
|
||||
CONFIG_SCHEMA_VERSION: "2020-11-18"
|
||||
VERSION: ${{ github.event.inputs.version }}
|
||||
STEAMPIPE_UPDATE_CHECK: false
|
||||
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
SPIPETOOLS_PG_CONN_STRING: ${{ secrets.SPIPETOOLS_PG_CONN_STRING }}
|
||||
SPIPETOOLS_TOKEN: ${{ secrets.SPIPETOOLS_TOKEN }}
|
||||
|
||||
jobs:
|
||||
|
||||
verify_input:
|
||||
name: Verify Inputs
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Trim asset version prefix and Validate
|
||||
run: |-
|
||||
echo $VERSION
|
||||
trim=${VERSION#"v"}
|
||||
echo $trim
|
||||
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
||||
echo "Version OK: $trim"
|
||||
else
|
||||
echo "Invalid version: $trim"
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION=${trim}" >> $GITHUB_ENV
|
||||
|
||||
- name: Validate Branch
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
ref: ${{ github.event.ref }}
|
||||
|
||||
create_test_build:
|
||||
name: Create Test Build
|
||||
runs-on: ubuntu-latest
|
||||
needs: [verify_input]
|
||||
steps:
|
||||
- name: Trim asset version prefix and Validate
|
||||
run: |-
|
||||
echo $VERSION
|
||||
trim=${VERSION#"v"}
|
||||
echo $trim
|
||||
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
||||
echo "Version OK: $trim"
|
||||
else
|
||||
echo "Invalid version: $trim"
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION=${trim}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: steampipe
|
||||
ref: ${{ github.event.ref }}
|
||||
|
||||
- name: Checkout Pipe Fittings Components repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/pipe-fittings
|
||||
path: pipe-fittings
|
||||
ref: v1.6.x
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
||||
with:
|
||||
go-version: 1.22
|
||||
|
||||
- name: Change directory to steampipe
|
||||
run: cd steampipe
|
||||
|
||||
- name: Run CLI Unit Tests
|
||||
run: |
|
||||
cd steampipe
|
||||
go clean -testcache
|
||||
go test -timeout 30s ./... -test.v
|
||||
|
||||
- name: Install GoReleaser
|
||||
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
|
||||
with:
|
||||
install-only: true
|
||||
|
||||
- name: Run GoReleaser
|
||||
run: |
|
||||
cd steampipe
|
||||
goreleaser release --clean --snapshot --skip=publish
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Move build artifacts
|
||||
run: |
|
||||
mkdir ~/artifacts
|
||||
mv $GITHUB_WORKSPACE/steampipe/dist/steampipe_linux_amd64.tar.gz ~/artifacts/linux.tar.gz
|
||||
mv $GITHUB_WORKSPACE/steampipe/dist/steampipe_linux_arm64.tar.gz ~/artifacts/linux-arm.tar.gz
|
||||
mv $GITHUB_WORKSPACE/steampipe/dist/steampipe_darwin_amd64.zip ~/artifacts/darwin.zip
|
||||
mv $GITHUB_WORKSPACE/steampipe/dist/steampipe_darwin_arm64.zip ~/artifacts/darwin-arm.zip
|
||||
|
||||
- name: List Build Artifacts
|
||||
run: ls -l ~/artifacts
|
||||
|
||||
- name: Save Linux Build Artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: build-artifact-linux
|
||||
path: ~/artifacts/linux.tar.gz
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
|
||||
- name: Save Linux ARM Build Artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: build-artifact-linux-arm
|
||||
path: ~/artifacts/linux-arm.tar.gz
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
|
||||
- name: Save MacOS Build Artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: build-artifact-darwin
|
||||
path: ~/artifacts/darwin.zip
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
|
||||
- name: Save MacOS ARM Build Artifact
|
||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
||||
with:
|
||||
name: build-artifact-darwin-arm
|
||||
path: ~/artifacts/darwin-arm.zip
|
||||
if-no-files-found: error
|
||||
overwrite: true
|
||||
|
||||
run_acceptance_tests:
|
||||
name: Acceptance tests
|
||||
needs: [create_test_build]
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
platform: [ubuntu-latest]
|
||||
test_block:
|
||||
- "migration"
|
||||
- "brew"
|
||||
- "installation"
|
||||
- "plugin"
|
||||
- "service"
|
||||
- "settings"
|
||||
- "ssl"
|
||||
- "blank_aggregators"
|
||||
- "search_path"
|
||||
- "chaos_and_query"
|
||||
- "dynamic_schema"
|
||||
- "dynamic_aggregators"
|
||||
- "cache"
|
||||
- "performance"
|
||||
- "config_precedence"
|
||||
- "cloud"
|
||||
- "snapshot"
|
||||
- "schema_cloning"
|
||||
- "exit_codes"
|
||||
- "force_stop"
|
||||
exclude:
|
||||
- platform: ubuntu-latest
|
||||
test_block: chaos_and_query
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- name: Trim asset version prefix and Validate
|
||||
run: |-
|
||||
echo $VERSION
|
||||
trim=${VERSION#"v"}
|
||||
echo $trim
|
||||
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
||||
echo "Version OK: $trim"
|
||||
else
|
||||
echo "Invalid version: $trim"
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION=${trim}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
submodules: true
|
||||
ref: ${{ github.event.ref }}
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
||||
with:
|
||||
go-version: 1.22
|
||||
|
||||
- name: Setup BATS
|
||||
uses: mig4/setup-bats@af9a00deb21b5d795cabfeaa8d9060410377686d # v1.2.0
|
||||
with:
|
||||
bats-version: 1.2.1
|
||||
|
||||
- name: Prepare for downloads
|
||||
id: prepare-for-downloads
|
||||
run: |
|
||||
mkdir ~/artifacts
|
||||
|
||||
- name: Download Linux Build Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: ${{ matrix.platform == 'ubuntu-latest' }}
|
||||
with:
|
||||
name: build-artifact-linux
|
||||
path: ~/artifacts
|
||||
|
||||
- name: Download Darwin Build Artifacts
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
if: ${{ matrix.platform == 'macos-13' }}
|
||||
with:
|
||||
name: build-artifact-darwin
|
||||
path: ~/artifacts
|
||||
|
||||
- name: Extract Ubuntu Artifacts and Install Binary
|
||||
if: ${{ matrix.platform == 'ubuntu-latest' }}
|
||||
run: |
|
||||
mkdir ~/build
|
||||
tar -xf ~/artifacts/linux.tar.gz -C ~/build
|
||||
|
||||
- name: Extract Darwin Artifacts and Install Binary
|
||||
if: ${{ matrix.platform == 'macos-13' }}
|
||||
run: |
|
||||
mkdir ~/build
|
||||
unzip ~/artifacts/darwin.zip -d ~/build
|
||||
|
||||
- name: Set PATH
|
||||
run: |
|
||||
echo "PATH=$PATH:$HOME/build:$GTIHUB_WORKSPACE/tests/acceptance/lib/bats-core/libexec" >> $GITHUB_ENV
|
||||
|
||||
- name: Go install jd
|
||||
run: |
|
||||
go install github.com/josephburnett/jd@latest
|
||||
|
||||
- name: Install DB
|
||||
id: install-db
|
||||
continue-on-error: false
|
||||
run: |
|
||||
steampipe service start
|
||||
steampipe plugin install chaos chaosdynamic
|
||||
steampipe service stop
|
||||
|
||||
- name: Run Test Suite
|
||||
id: run-test-suite
|
||||
timeout-minutes: 15
|
||||
run: |
|
||||
chmod +x $GITHUB_WORKSPACE/tests/acceptance/run.sh
|
||||
$GITHUB_WORKSPACE/tests/acceptance/run.sh ${{ matrix.test_block }}.bats
|
||||
steampipe service stop --force
|
||||
|
||||
smoke_test_ubuntu_24:
|
||||
name: Smoke test (Ubuntu 24, x86_64)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [create_test_build]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Download Linux Build Artifact
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: build-artifact-linux
|
||||
path: ./artifacts
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
|
||||
|
||||
- name: Pull Ubuntu latest Image
|
||||
run: docker pull ubuntu:latest
|
||||
|
||||
- name: Create and Start Ubuntu latest Container
|
||||
run: |
|
||||
docker run -d --name ubuntu-24-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts ubuntu:latest tail -f /dev/null
|
||||
|
||||
- name: Get runner/container info
|
||||
run: |
|
||||
docker exec ubuntu-24-test /scripts/linux_container_info.sh
|
||||
|
||||
- name: Install dependencies, create user, and assign necessary permissions
|
||||
run: |
|
||||
docker exec ubuntu-24-test /scripts/prepare_ubuntu_container.sh
|
||||
|
||||
- name: Run smoke tests
|
||||
run: |
|
||||
docker exec -u steampipe ubuntu-24-test /scripts/smoke_test.sh
|
||||
|
||||
- name: Stop and Remove Container
|
||||
run: |
|
||||
docker stop ubuntu-24-test
|
||||
docker rm ubuntu-24-test
|
||||
|
||||
smoke_test_centos_9:
|
||||
name: Smoke test (Centos stream 9, x86_64)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [create_test_build]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Download Linux Build Artifact
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: build-artifact-linux
|
||||
path: ./artifacts
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
|
||||
|
||||
- name: Pull CentOS Stream 9 image
|
||||
run: docker pull quay.io/centos/centos:stream9
|
||||
|
||||
- name: Create and Start CentOS stream9 Container
|
||||
run: |
|
||||
docker run -d --name centos-stream9-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts quay.io/centos/centos:stream9 tail -f /dev/null
|
||||
|
||||
- name: Get runner/container info
|
||||
run: |
|
||||
docker exec centos-stream9-test /scripts/linux_container_info.sh
|
||||
|
||||
- name: Install dependencies, create user, and assign necessary permissions
|
||||
run: |
|
||||
docker exec centos-stream9-test /scripts/prepare_centos_container.sh
|
||||
|
||||
- name: Run smoke tests
|
||||
run: |
|
||||
docker exec -u steampipe centos-stream9-test /scripts/smoke_test.sh
|
||||
|
||||
- name: Stop and Remove Container
|
||||
run: |
|
||||
docker stop centos-stream9-test
|
||||
docker rm centos-stream9-test
|
||||
|
||||
smoke_test_amazonlinux:
|
||||
name: Smoke test (Amazonlinux 2023, x86_64)
|
||||
runs-on: ubuntu-latest
|
||||
needs: [create_test_build]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Download Linux Build Artifact
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: build-artifact-linux
|
||||
path: ./artifacts
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@b5ca514318bd6ebac0fb2aedd5d36ec1b5c232a2 # v3.10.0
|
||||
|
||||
- name: Pull Amazon Linux 2023 Image
|
||||
run: docker pull amazonlinux:2023
|
||||
|
||||
- name: Create and Start Amazon Linux 2023 Container
|
||||
run: |
|
||||
docker run -d --name amazonlinux-2023-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts amazonlinux:2023 tail -f /dev/null
|
||||
|
||||
- name: Get runner/container info
|
||||
run: |
|
||||
docker exec amazonlinux-2023-test /scripts/linux_container_info.sh
|
||||
|
||||
- name: Install dependencies, create user, and assign necessary permissions
|
||||
run: |
|
||||
docker exec amazonlinux-2023-test /scripts/prepare_amazonlinux_container.sh
|
||||
|
||||
- name: Run smoke tests
|
||||
run: |
|
||||
docker exec -u steampipe amazonlinux-2023-test /scripts/smoke_test.sh
|
||||
|
||||
- name: Stop and Remove Container
|
||||
run: |
|
||||
docker stop amazonlinux-2023-test
|
||||
docker rm amazonlinux-2023-test
|
||||
|
||||
# TODO (pskr) fix and enable this test
|
||||
# smoke_test_ubuntu_24_arm64:
|
||||
# name: Smoke test (Ubuntu 24, ARM64)
|
||||
# runs-on: ubuntu-latest
|
||||
# needs: [create_test_build]
|
||||
# steps:
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v4
|
||||
|
||||
# - name: Download Linux Build Artifact
|
||||
# uses: actions/download-artifact@v4
|
||||
# with:
|
||||
# name: build-artifact-linux-arm
|
||||
# path: ./artifacts
|
||||
|
||||
# - name: Set up Docker Buildx
|
||||
# uses: docker/setup-buildx-action@v3
|
||||
|
||||
# - name: Set up QEMU
|
||||
# uses: docker/setup-qemu-action@v3
|
||||
# with:
|
||||
# platforms: arm64
|
||||
|
||||
# - name: Create Buildx Builder
|
||||
# run: |
|
||||
# docker buildx create --use --name mybuilder
|
||||
# docker buildx inspect --bootstrap
|
||||
|
||||
# - name: Pull Ubuntu 24 ARM64 Image
|
||||
# run: docker pull arm64v8/ubuntu:latest
|
||||
|
||||
# - name: Create and Start Ubuntu 24 ARM64 Container
|
||||
# run: |
|
||||
# docker run -d --name ubuntu-24-arm64-test -v ${{ github.workspace }}/artifacts:/artifacts -v ${{ github.workspace }}/scripts:/scripts arm64v8/ubuntu:latest tail -f /dev/null
|
||||
|
||||
# - name: Get runner/container info
|
||||
# run: |
|
||||
# docker exec ubuntu-24-arm64-test /scripts/linux_container_info.sh
|
||||
|
||||
# - name: Install dependencies, create user, and assign necessary permissions
|
||||
# run: |
|
||||
# docker exec ubuntu-24-arm64-test /scripts/prepare_ubuntu_arm_container.sh
|
||||
|
||||
# - name: Run smoke tests
|
||||
# run: |
|
||||
# docker exec -u steampipe ubuntu-24-arm64-test /scripts/smoke_test.sh
|
||||
|
||||
# - name: Stop and Remove Container
|
||||
# run: |
|
||||
# docker stop ubuntu-24-arm64-test
|
||||
# docker rm ubuntu-24-arm64-test
|
||||
|
||||
smoke_test_darwin_arm:
|
||||
name: Smoke test (MacOS 14, ARM64)
|
||||
runs-on: macos-latest
|
||||
needs: [create_test_build]
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
|
||||
- name: Download Darwin Build Artifact
|
||||
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
|
||||
with:
|
||||
name: build-artifact-darwin-arm
|
||||
path: ~/artifacts
|
||||
|
||||
- name: Extract Darwin Artifacts and Install Binary
|
||||
run: |
|
||||
unzip ~/artifacts/darwin-arm.zip -d /usr/local/bin
|
||||
|
||||
- name: Install jq
|
||||
run: |
|
||||
brew install jq
|
||||
|
||||
- name: Get runner/container info
|
||||
run: |
|
||||
uname -a
|
||||
sw_vers
|
||||
|
||||
- name: Run Smoke tests
|
||||
run: |
|
||||
ls -al $GITHUB_WORKSPACE/scripts
|
||||
chmod +x $GITHUB_WORKSPACE/scripts/smoke_test.sh
|
||||
$GITHUB_WORKSPACE/scripts/smoke_test.sh
|
||||
|
||||
create_release_tag:
|
||||
name: Tag Release
|
||||
needs: [run_acceptance_tests, smoke_test_ubuntu_24, smoke_test_amazonlinux, smoke_test_centos_9, smoke_test_darwin_arm]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Trim asset version prefix and Validate
|
||||
run: |-
|
||||
echo $VERSION
|
||||
trim=${VERSION#"v"}
|
||||
echo $trim
|
||||
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
||||
echo "Version OK: $trim"
|
||||
else
|
||||
echo "Invalid version: $trim"
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION=${trim}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
ref: ${{ github.event.ref }}
|
||||
|
||||
- name: Unshallow
|
||||
run: git fetch --prune --unshallow
|
||||
|
||||
- name: Tag Release
|
||||
run: |
|
||||
git config user.name "Steampipe GitHub Actions Bot"
|
||||
git config user.email noreply@github.com
|
||||
git tag ${{ github.event.inputs.version }}
|
||||
git push origin ${{ github.event.inputs.version }}
|
||||
|
||||
ensure_branch_in_homebrew:
|
||||
name: Ensure branch exists in homebrew-tap
|
||||
needs: [create_release_tag]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Parse semver string
|
||||
id: semver_parser
|
||||
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
|
||||
with:
|
||||
input_string: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Checkout
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: main
|
||||
|
||||
- name: Delete base branch if exists
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
git fetch --all
|
||||
git push origin --delete bump-brew
|
||||
git push origin --delete $VERSION
|
||||
continue-on-error: true
|
||||
|
||||
- name: Create base branch
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
git checkout -b bump-brew
|
||||
git push --set-upstream origin bump-brew
|
||||
|
||||
build_and_release_cli:
|
||||
name: Release CLI
|
||||
needs: [create_release_tag, ensure_branch_in_homebrew]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Trim asset version prefix and Validate
|
||||
run: |-
|
||||
echo $VERSION
|
||||
trim=${VERSION#"v"}
|
||||
echo $trim
|
||||
if [[ $trim =~ ^[0-9]+\.[0-9]+\.[0-9]+(-.+)?$ ]]; then
|
||||
echo "Version OK: $trim"
|
||||
else
|
||||
echo "Invalid version: $trim"
|
||||
exit 1
|
||||
fi
|
||||
echo "VERSION=${trim}" >> $GITHUB_ENV
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
path: steampipe
|
||||
ref: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Checkout Pipe Fittings Components repository
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/pipe-fittings
|
||||
path: pipe-fittings
|
||||
ref: v1.6.x
|
||||
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@d35c59abb061a4a6fb18e82ac0862c26744d6ab5 # v5.5.0
|
||||
with:
|
||||
go-version: 1.22
|
||||
|
||||
- name: Install GoReleaser
|
||||
uses: goreleaser/goreleaser-action@9c156ee8a17a598857849441385a2041ef570552 # v6.3.0
|
||||
with:
|
||||
install-only: true
|
||||
|
||||
- name: Run GoReleaser
|
||||
run: |
|
||||
cd steampipe
|
||||
goreleaser release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
|
||||
create_pr_in_homebrew:
|
||||
name: Create PR in homebrew-tap
|
||||
needs: [ensure_branch_in_homebrew, build_and_release_cli]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Version: ${{ github.event.inputs.version }}
|
||||
steps:
|
||||
- name: Parse semver string
|
||||
id: semver_parser
|
||||
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
|
||||
with:
|
||||
input_string: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Checkout
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: main
|
||||
|
||||
- name: Create a new branch off the base branch
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
git fetch --all
|
||||
git checkout bump-brew
|
||||
git checkout -b $VERSION
|
||||
git push --set-upstream origin $VERSION
|
||||
|
||||
- name: Close pull request if already exists
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
gh pr close $VERSION
|
||||
continue-on-error: true
|
||||
|
||||
- name: Create pull request
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
gh pr create --base main --head $VERSION --title "$Version" --body "Update formula"
|
||||
|
||||
update_pr_for_versioning:
|
||||
name: Update PR
|
||||
needs: [create_pr_in_homebrew]
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
Version: ${{ github.event.inputs.version }}
|
||||
steps:
|
||||
- name: Parse semver string
|
||||
id: semver_parser
|
||||
uses: booxmedialtd/ws-action-parse-semver@7784200024d6b3fc01253e617ec0168daf603de3 # v1.4.7
|
||||
with:
|
||||
input_string: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Checkout
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
||||
with:
|
||||
repository: turbot/homebrew-tap
|
||||
token: ${{ secrets.GH_ACCESS_TOKEN }}
|
||||
ref: ${{ github.event.inputs.version }}
|
||||
|
||||
- name: Update live version
|
||||
if: steps.semver_parser.outputs.prerelease == ''
|
||||
run: |
|
||||
scripts/formula_versioning.sh
|
||||
git config --global user.email "puskar@turbot.com"
|
||||
git config --global user.name "Puskar Basu"
|
||||
git add .
|
||||
git commit -m "Versioning brew formulas"
|
||||
git push origin $VERSION
|
||||
|
||||
clean_up:
|
||||
# let's clean up the artifacts.
|
||||
# in case this step isn't reached,
|
||||
# artifacts automatically expire after 90 days anyway
|
||||
# refer:
|
||||
# https://docs.github.com/en/actions/configuring-and-managing-workflows/persisting-workflow-data-using-artifacts#downloading-and-deleting-artifacts-after-a-workflow-run-is-complete
|
||||
name: Clean Up Artifacts
|
||||
needs: update_pr_for_versioning
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Clean up Linux Build
|
||||
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
|
||||
with:
|
||||
name: build-artifact-linux
|
||||
|
||||
- name: Clean up Darwin Build
|
||||
uses: geekyeggo/delete-artifact@f275313e70c08f6120db482d7a6b98377786765b # v5.1.0
|
||||
with:
|
||||
name: build-artifact-darwin
|
||||
@@ -17,6 +17,11 @@ builds:
|
||||
id: "steampipe"
|
||||
binary:
|
||||
'steampipe'
|
||||
ldflags:
|
||||
# Go Releaser analyzes your Git repository and identifies the most recent Git tag (typically the highest version number) as the version for your release.
|
||||
# This is how it determines the value of {{.Version}}.
|
||||
- -s -w -X main.version={{.Version}} -X main.date={{.Date}} -X main.commit={{.Commit}} -X main.builtBy=goreleaser
|
||||
|
||||
archives:
|
||||
- files:
|
||||
- none*
|
||||
@@ -55,9 +60,10 @@ snapshot:
|
||||
|
||||
checksum:
|
||||
name_template: 'checksums.txt'
|
||||
|
||||
release:
|
||||
# Visit your project's GitHub Releases page to publish this release.
|
||||
draft: true
|
||||
prerelease: auto
|
||||
|
||||
changelog:
|
||||
disable: true
|
||||
|
||||
|
||||
13
Makefile
13
Makefile
@@ -1,12 +1,15 @@
|
||||
OUTPUT_DIR?=/usr/local/bin
|
||||
|
||||
steampipe:
|
||||
go build -o ${OUTPUT_DIR}/steampipe
|
||||
build:
|
||||
$(eval TIMESTAMP := $(shell date +%Y%m%d%H%M%S))
|
||||
$(eval GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/[\/_]/-/g' | sed 's/[^a-zA-Z0-9.-]//g'))
|
||||
|
||||
dashboard_assets:
|
||||
$(MAKE) -C ui/dashboard
|
||||
go build -o $(OUTPUT_DIR) -ldflags "-X main.version=0.0.0-dev-$(GIT_BRANCH).$(TIMESTAMP)" .
|
||||
|
||||
all:
|
||||
$(MAKE) -C pkg/pluginmanager_service
|
||||
$(MAKE) -C ui/dashboard
|
||||
go build -o ${OUTPUT_DIR}/steampipe
|
||||
$(eval TIMESTAMP := $(shell date +%Y%m%d%H%M%S))
|
||||
$(eval GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed 's/[\/_]/-/g' | sed 's/[^a-zA-Z0-9.-]//g'))
|
||||
|
||||
go build -o $(OUTPUT_DIR) -ldflags "-X main.version=0.0.0-dev-$(GIT_BRANCH).$(TIMESTAMP)" .
|
||||
|
||||
@@ -2,7 +2,6 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/mattn/go-isatty"
|
||||
@@ -14,7 +13,6 @@ import (
|
||||
"github.com/turbot/pipe-fittings/v2/utils"
|
||||
"github.com/turbot/steampipe/pkg/error_helpers"
|
||||
"github.com/turbot/steampipe/pkg/statushooks"
|
||||
"github.com/turbot/steampipe/pkg/version"
|
||||
)
|
||||
|
||||
var exitCode int
|
||||
@@ -22,7 +20,6 @@ var exitCode int
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "steampipe [--version] [--help] COMMAND [args]",
|
||||
Version: version.SteampipeVersion.String(),
|
||||
Short: "Query cloud resources using SQL",
|
||||
Long: `Steampipe: select * from cloud;
|
||||
|
||||
@@ -53,7 +50,10 @@ func InitCmd() {
|
||||
|
||||
defaultInstallDir, err := filehelpers.Tildefy(app_specific.DefaultInstallDir)
|
||||
error_helpers.FailOnError(err)
|
||||
rootCmd.SetVersionTemplate(fmt.Sprintf("Steampipe v%s\n", version.SteampipeVersion.String()))
|
||||
|
||||
// Set the version after viper has been initialized
|
||||
rootCmd.Version = viper.GetString("main.version")
|
||||
rootCmd.SetVersionTemplate("Steampipe v{{.Version}}\n")
|
||||
|
||||
// global flags
|
||||
rootCmd.PersistentFlags().String(constants.ArgWorkspaceProfile, "default", "The workspace profile to use") // workspace profile profile is a global flag since install-dir(global) can be set through the workspace profile
|
||||
@@ -70,7 +70,6 @@ func InitCmd() {
|
||||
// powershell yet - and there's no way to disable powershell in the default generator
|
||||
rootCmd.CompletionOptions.DisableDefaultCmd = true
|
||||
rootCmd.Flags().BoolP(constants.ArgHelp, "h", false, "Help for steampipe")
|
||||
rootCmd.Flags().BoolP(constants.ArgVersion, "v", false, "Version for steampipe")
|
||||
|
||||
hideRootFlags(constants.ArgSchemaComments)
|
||||
|
||||
|
||||
26
main.go
26
main.go
@@ -9,18 +9,28 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/hashicorp/go-version"
|
||||
go_version "github.com/hashicorp/go-version"
|
||||
_ "github.com/jackc/pgx/v5/stdlib"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/go-kit/helpers"
|
||||
"github.com/turbot/pipe-fittings/v2/utils"
|
||||
"github.com/turbot/steampipe/cmd"
|
||||
"github.com/turbot/steampipe/pkg/cmdconfig"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
localconstants "github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/error_helpers"
|
||||
)
|
||||
|
||||
var exitCode int = constants.ExitCodeSuccessful
|
||||
|
||||
var (
|
||||
// these variables will be set by GoReleaser
|
||||
version = localconstants.DefaultVersion
|
||||
commit = localconstants.DefaultCommit
|
||||
date = localconstants.DefaultDate
|
||||
builtBy = localconstants.DefaultBuiltBy
|
||||
)
|
||||
|
||||
func main() {
|
||||
ctx := context.Background()
|
||||
utils.LogTime("main start")
|
||||
@@ -36,6 +46,9 @@ func main() {
|
||||
os.Exit(exitCode)
|
||||
}()
|
||||
|
||||
// add the auto-populated version properties into viper
|
||||
setVersionProperties()
|
||||
|
||||
// ensure steampipe is not being run as root
|
||||
checkRoot(ctx)
|
||||
|
||||
@@ -98,13 +111,13 @@ func checkWsl1(ctx context.Context) {
|
||||
|
||||
// store the system kernel version
|
||||
sys_kernel, _, _ := strings.Cut(string(output), "-")
|
||||
sys_kernel_ver, err := version.NewVersion(sys_kernel)
|
||||
sys_kernel_ver, err := go_version.NewVersion(sys_kernel)
|
||||
if err != nil {
|
||||
error_helpers.ShowErrorWithMessage(ctx, err, "failed to check system kernel version")
|
||||
return
|
||||
}
|
||||
// if the kernel version >= 4.19, it's WSL Version 2.
|
||||
kernel_ver, err := version.NewVersion("4.19")
|
||||
kernel_ver, err := go_version.NewVersion("4.19")
|
||||
if err != nil {
|
||||
error_helpers.ShowErrorWithMessage(ctx, err, "checking system kernel version")
|
||||
return
|
||||
@@ -150,3 +163,10 @@ func checkOSXVersion(ctx context.Context) {
|
||||
os.Exit(constants.ExitCodeInvalidExecutionEnvironment)
|
||||
}
|
||||
}
|
||||
|
||||
func setVersionProperties() {
|
||||
viper.SetDefault(constants.ConfigKeyVersion, version)
|
||||
viper.SetDefault(constants.ConfigKeyCommit, commit)
|
||||
viper.SetDefault(constants.ConfigKeyDate, date)
|
||||
viper.SetDefault(constants.ConfigKeyBuiltBy, builtBy)
|
||||
}
|
||||
|
||||
@@ -3,20 +3,22 @@ package cmdconfig
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
"github.com/spf13/viper"
|
||||
pfilepaths "github.com/turbot/pipe-fittings/v2/filepaths"
|
||||
|
||||
"github.com/turbot/go-kit/files"
|
||||
"github.com/turbot/pipe-fittings/v2/app_specific"
|
||||
"github.com/turbot/pipe-fittings/v2/error_helpers"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/version"
|
||||
)
|
||||
|
||||
// SetAppSpecificConstants sets app specific constants defined in pipe-fittings
|
||||
func SetAppSpecificConstants() {
|
||||
app_specific.AppName = "steampipe"
|
||||
|
||||
app_specific.AppVersion = version.SteampipeVersion
|
||||
versionString := viper.GetString("main.version")
|
||||
app_specific.AppVersion = semver.MustParse(versionString)
|
||||
|
||||
app_specific.SetAppSpecificEnvVarKeys("STEAMPIPE_")
|
||||
app_specific.ConfigExtension = ".spc"
|
||||
|
||||
@@ -38,7 +38,6 @@ import (
|
||||
"github.com/turbot/steampipe/pkg/filepaths"
|
||||
"github.com/turbot/steampipe/pkg/steampipeconfig"
|
||||
"github.com/turbot/steampipe/pkg/task"
|
||||
"github.com/turbot/steampipe/pkg/version"
|
||||
)
|
||||
|
||||
var waitForTasksChannel chan struct{}
|
||||
@@ -385,7 +384,7 @@ func createLogger(logBuffer *bytes.Buffer, cmd *cobra.Command) {
|
||||
// we need to do this since all instances will log to a single file and logs will be interleaved
|
||||
log.Printf("[INFO] ********************************************************\n")
|
||||
log.Printf("[INFO] steampipe %s [%s]", cmd.Name(), runtime.ExecutionID)
|
||||
log.Printf("[INFO] Version: v%s\n", version.VersionString)
|
||||
log.Printf("[INFO] Version: v%s\n", viper.GetString("main.version"))
|
||||
log.Printf("[INFO] Log level: %s\n", sdklogging.LogLevel())
|
||||
log.Printf("[INFO] Log date: %s\n", time.Now().Format("2006-01-02"))
|
||||
log.Printf("[INFO] ********************************************************\n")
|
||||
|
||||
17
pkg/constants/build.go
Normal file
17
pkg/constants/build.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package constants
|
||||
|
||||
const (
|
||||
ConfigKeyVersion = "main.version"
|
||||
ConfigKeyCommit = "main.commit"
|
||||
ConfigKeyDate = "main.date"
|
||||
ConfigKeyBuiltBy = "main.builtBy"
|
||||
|
||||
LocalBuild = DefaultBuiltBy
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultVersion = "0.0.0"
|
||||
DefaultCommit = "none"
|
||||
DefaultDate = "unknown"
|
||||
DefaultBuiltBy = "local"
|
||||
)
|
||||
@@ -1,19 +0,0 @@
|
||||
package constants
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/turbot/steampipe/pkg/version"
|
||||
)
|
||||
|
||||
// DashboardListenAddresses is an arrays is listen addresses which Steampipe accepts
|
||||
var DashboardListenAddresses = []string{"localhost", "127.0.0.1"}
|
||||
|
||||
const (
|
||||
DashboardServerDefaultPort = 9194
|
||||
DashboardAssetsImageRefFormat = "us-docker.pkg.dev/steampipe/steampipe/assets:%s"
|
||||
)
|
||||
|
||||
var (
|
||||
DashboardAssetsImageRef = fmt.Sprintf(DashboardAssetsImageRefFormat, version.VersionString)
|
||||
)
|
||||
@@ -11,7 +11,6 @@ import (
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
"github.com/turbot/steampipe/pkg/db/db_common"
|
||||
"github.com/turbot/steampipe/pkg/serversettings"
|
||||
"github.com/turbot/steampipe/pkg/version"
|
||||
)
|
||||
|
||||
// setupServerSettingsTable creates a new read-only table with information in the current
|
||||
@@ -21,7 +20,7 @@ import (
|
||||
func setupServerSettingsTable(ctx context.Context, conn *pgx.Conn) error {
|
||||
settings := db_common.ServerSettings{
|
||||
StartTime: time.Now(),
|
||||
SteampipeVersion: version.VersionString,
|
||||
SteampipeVersion: viper.GetString("main.version"),
|
||||
FdwVersion: constants.FdwVersion,
|
||||
CacheMaxTtl: viper.GetInt(pconstants.ArgCacheMaxTtl),
|
||||
CacheMaxSizeMb: viper.GetInt(pconstants.ArgMaxCacheSizeMb),
|
||||
|
||||
@@ -33,7 +33,6 @@ import (
|
||||
"github.com/turbot/steampipe/pkg/query/queryhistory"
|
||||
"github.com/turbot/steampipe/pkg/statushooks"
|
||||
"github.com/turbot/steampipe/pkg/steampipeconfig"
|
||||
"github.com/turbot/steampipe/pkg/version"
|
||||
)
|
||||
|
||||
type AfterPromptCloseAction int
|
||||
@@ -131,7 +130,7 @@ func (c *InteractiveClient) InteractivePrompt(parentContext context.Context) {
|
||||
|
||||
statushooks.Message(
|
||||
ctx,
|
||||
fmt.Sprintf("Welcome to Steampipe v%s", version.SteampipeVersion.String()),
|
||||
fmt.Sprintf("Welcome to Steampipe v%s", viper.GetString("main.version")),
|
||||
fmt.Sprintf("For more information, type %s", pconstants.Bold(".help")),
|
||||
)
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
package ociinstaller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"path/filepath"
|
||||
|
||||
"github.com/turbot/pipe-fittings/v2/ociinstaller"
|
||||
"github.com/turbot/steampipe/pkg/constants"
|
||||
)
|
||||
|
||||
// InstallAssets installs the Steampipe report server assets
|
||||
func InstallAssets(ctx context.Context, assetsLocation string) error {
|
||||
tempDir := ociinstaller.NewTempDir(assetsLocation)
|
||||
defer func() {
|
||||
if err := tempDir.Delete(); err != nil {
|
||||
log.Printf("[TRACE] Failed to delete temp dir '%s' after installing assets: %s", tempDir, err)
|
||||
}
|
||||
}()
|
||||
|
||||
// download the blobs
|
||||
imageDownloader := newAssetDownloader()
|
||||
image, err := imageDownloader.Download(ctx, ociinstaller.NewImageRef(constants.DashboardAssetsImageRef), ImageTypeAssets, tempDir.Path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// install the files
|
||||
if err = installAssetsFiles(image, tempDir.Path, assetsLocation); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func installAssetsFiles(image *ociinstaller.OciImage[*assetsImage, *assetsImageConfig], tempdir string, dest string) error {
|
||||
fileName := image.Data.ReportUI
|
||||
sourcePath := filepath.Join(tempdir, fileName)
|
||||
if err := ociinstaller.MoveFolderWithinPartition(sourcePath, dest); err != nil {
|
||||
return fmt.Errorf("could not install %s to %s", sourcePath, dest)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -9,13 +9,13 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-git/go-git/v5/plumbing/transport/http"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/turbot/pipe-fittings/v2/app_specific"
|
||||
"github.com/turbot/pipe-fittings/v2/utils"
|
||||
"github.com/turbot/steampipe/pkg/version"
|
||||
)
|
||||
|
||||
// the current version of the Steampipe CLI application
|
||||
var currentVersion = version.SteampipeVersion.String()
|
||||
var currentVersion = viper.GetString("main.version")
|
||||
|
||||
type CLIVersionCheckResponse struct {
|
||||
NewVersion string `json:"latest_version,omitempty"` // `json:"current_version"`
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
// Package version :: The version package provides a location to set the release versions for all
|
||||
// packages to consume, without creating import cycles.
|
||||
//
|
||||
// This package should not import any other steampipe packages.
|
||||
package version
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/Masterminds/semver/v3"
|
||||
)
|
||||
|
||||
/**
|
||||
We should fill in the `steampipeVersion` and `prerelease` variables using ldflags during build
|
||||
|
||||
See https://blog.alexellis.io/inject-build-time-vars-golang/
|
||||
Also https://www.digitalocean.com/community/tutorials/using-ldflags-to-set-version-information-for-go-applications
|
||||
**/
|
||||
|
||||
// The main version number that is being run at the moment.
|
||||
var steampipeVersion = "2.0.1"
|
||||
|
||||
// A pre-release marker for the version. If this is "" (empty string)
|
||||
// then it means that it is a final release. Otherwise, this is a pre-release
|
||||
// such as "dev" (in development), "beta", "rc1", etc.
|
||||
var prerelease = ""
|
||||
|
||||
// SteampipeVersion is an instance of semver.Version. This has the secondary
|
||||
// benefit of verifying during tests and init time that our version is a
|
||||
// proper semantic version, which should always be the case.
|
||||
var SteampipeVersion *semver.Version
|
||||
|
||||
var VersionString string
|
||||
|
||||
func init() {
|
||||
VersionString = steampipeVersion
|
||||
if prerelease != "" {
|
||||
VersionString = fmt.Sprintf("%s-%s", steampipeVersion, prerelease)
|
||||
}
|
||||
SteampipeVersion = semver.MustParse(VersionString)
|
||||
}
|
||||
Reference in New Issue
Block a user