Adds stability to version tagging and apt/yum in workflows. Closes #1431 (#1432)

This commit is contained in:
Binaek Sarkar authored and GitHub committed 2022-02-14 14:17:09 +00:00
1 parent 95334d456b
commit d1945dabfb
3 files changed
+279 -177

No files matched your search

+1 -1
View File
@@ -22,7 +22,7 @@ updates:
pull-request-branch-name:
separator: "-"
assignees:
- "binaek89"
- "binaek"
- "kaidaguerre"
labels:
- "dependencies"
+42 -18
View File
@@ -5,13 +5,14 @@ on:
branch:
description: "The branch that will be built"
required: true
tag:
description: "The release tag that will be set"
version:
description: "The version to release (must be prefixed with 'v')"
required: true
env:
PROJECT_ID: steampipe
STEAMPIPE_UPDATE_CHECK: false
VERSION: ${{ github.event.inputs.version }}
jobs:
goreleaser:
@@ -133,11 +134,25 @@ jobs:
$GITHUB_WORKSPACE/tests/acceptance/run.sh
steampipe service stop --force
create_release:
name: Release
create_release_tag:
name: Tag Release
needs: [goreleaser, acceptance_test]
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@v2
with:
@@ -146,20 +161,27 @@ jobs:
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Hook private repo
run: git config --global url."https://${{ secrets.GH_ACCESS_TOKEN }}:[email protected]".insteadOf "https://github.com"
- name: Tag Release
run: |
git config user.name "Steampipe GitHub Actions Bot"
git config user.email [email protected]
git tag ${{ github.event.inputs.tag }}
git push origin ${{ github.event.inputs.tag }}
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
create_release:
name: Release
needs: [create_release_tag]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.version }}
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
@@ -169,15 +191,17 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: google-github-actions/setup-gcloud@v0.5.0
- name: Setup GCloud CLI
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS }}
project_id: ${{ env.PROJECT_ID }}
export_default_credentials: true
- run: gcloud config list
- run: gcloud components install beta
- name: Install GCloud Beta Components
run: |-
gcloud config list
gcloud components install beta
- name: Upload rpm and deb packages to artifact registry
run: |
+236 -158
View File
@@ -1,4 +1,5 @@
name: Steampipe Release (CLI and Assets)
on:
workflow_dispatch:
inputs:
@@ -6,7 +7,7 @@ on:
description: "The branch that will be built"
required: true
version:
description: "The desired semver compatible version string (MUST to be prefixed with a 'v')"
description: "The version to release (must be prefixed with 'v')"
required: true
env:
@@ -24,23 +25,23 @@ jobs:
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@v2
with:
ref: ${{ github.event.inputs.branch }}
- 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@v2
with:
ref: ${{ github.event.inputs.branch }}
verify_asset_unreleased:
name: Verify Assets Unreleased
@@ -51,6 +52,19 @@ jobs:
status: ${{ steps.verify.conclusion }}
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: Get GCloud CLI
uses: google-github-actions/[email protected]
with:
@@ -77,6 +91,18 @@ jobs:
if: needs.verify_asset_unreleased.outputs.status == 'success'
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: Get GCloud CLI
uses: google-github-actions/[email protected]
@@ -108,27 +134,27 @@ jobs:
node-version: '16'
- name: Setup Yarn
working-directory: ./ui/report
run: |-
rm -rf ./build
working-directory: ./ui/report
- name: YARN Install
working-directory: ./ui/report
run: |-
unset CI
yarn install
working-directory: ./ui/report
- name: Run Unit Tests
working-directory: ./ui/report
run: |
yarn install
CI=true yarn test
working-directory: ./ui/report
- name: YARN Build
working-directory: ./ui/report
run: |-
unset CI
yarn build
working-directory: ./ui/report
- name: Move Build Assets
run: |-
@@ -205,49 +231,62 @@ jobs:
runs-on: ubuntu-latest
needs: [verify_input]
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
- 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@v2
with:
ref: ${{ github.event.inputs.branch }}
- name: Unshallow
run: git fetch
- name: Unshallow
run: git fetch
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --snapshot --rm-dist --skip-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --snapshot --rm-dist --skip-publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Move build artifacts
run: |
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/dist/steampipe_linux_amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/dist/steampipe_darwin_amd64.zip ~/artifacts/darwin.zip
- name: Move build artifacts
run: |
mkdir ~/artifacts
mv $GITHUB_WORKSPACE/dist/steampipe_linux_amd64.tar.gz ~/artifacts/linux.tar.gz
mv $GITHUB_WORKSPACE/dist/steampipe_darwin_amd64.zip ~/artifacts/darwin.zip
- name: List Build Artifacts
run: ls -l ~/artifacts
- name: List Build Artifacts
run: ls -l ~/artifacts
- name: Save Linux Build Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact-linux
path: ~/artifacts/linux.tar.gz
if-no-files-found: error
- name: Save Linux Build Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact-linux
path: ~/artifacts/linux.tar.gz
if-no-files-found: error
- name: Save MacOS Build Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact-darwin
path: ~/artifacts/darwin.zip
if-no-files-found: error
- name: Save MacOS Build Artifact
uses: actions/upload-artifact@v2
with:
name: build-artifact-darwin
path: ~/artifacts/darwin.zip
if-no-files-found: error
run_acceptance_tests:
name: Run CLI Acceptance tests
@@ -257,127 +296,166 @@ jobs:
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: true
ref: ${{ github.event.inputs.branch }}
- 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@v2
with:
submodules: true
ref: ${{ github.event.inputs.branch }}
- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.2.1
- name: Setup BATS
uses: mig4/setup-bats@v1
with:
bats-version: 1.2.1
- name: Prepare for downloads
id: prepare-for-downloads
run: |
mkdir ~/artifacts
- name: Prepare for downloads
id: prepare-for-downloads
run: |
mkdir ~/artifacts
- name: Download Linux Build Artifacts
uses: actions/download-artifact@v2
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: build-artifact-linux
path: ~/artifacts
- name: Download Linux Build Artifacts
uses: actions/download-artifact@v2
if: ${{ matrix.platform == 'ubuntu-latest' }}
with:
name: build-artifact-linux
path: ~/artifacts
- name: Download Darwin Build Artifacts
uses: actions/download-artifact@v2
if: ${{ matrix.platform == 'macos-latest' }}
with:
name: build-artifact-darwin
path: ~/artifacts
- name: Download Darwin Build Artifacts
uses: actions/download-artifact@v2
if: ${{ matrix.platform == 'macos-latest' }}
with:
name: build-artifact-darwin
path: ~/artifacts
- name: Extract Darwin Artifacts and Install Binary
if: ${{ matrix.platform == 'macos-latest' }}
run: |
mkdir ~/build
unzip ~/artifacts/darwin.zip -d ~/build
- name: Extract Darwin Artifacts and Install Binary
if: ${{ matrix.platform == 'macos-latest' }}
run: |
mkdir ~/build
unzip ~/artifacts/darwin.zip -d ~/build
- 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 Ubuntu Artifacts and Install Binary
if: ${{ matrix.platform == 'ubuntu-latest' }}
run: |
mkdir ~/build
tar -xf ~/artifacts/linux.tar.gz -C ~/build
- name: Set PATH
run: |
echo "PATH=$PATH:$HOME/build:$GTIHUB_WORKSPACE/tests/acceptance/lib/bats/bin" >> $GITHUB_ENV
- name: Set PATH
run: |
echo "PATH=$PATH:$HOME/build:$GTIHUB_WORKSPACE/tests/acceptance/lib/bats/bin" >> $GITHUB_ENV
- name: Install DB
run: |
steampipe service start
steampipe plugin install chaos
steampipe service stop --force
- name: Install DB
run: |
steampipe service start
steampipe plugin install chaos
steampipe service stop --force
- name: Run Test Suite
timeout-minutes: 5
run: |
chmod +x $GITHUB_WORKSPACE/tests/acceptance/run.sh
$GITHUB_WORKSPACE/tests/acceptance/run.sh
steampipe service stop --force
- name: Run Test Suite
timeout-minutes: 5
run: |
chmod +x $GITHUB_WORKSPACE/tests/acceptance/run.sh
$GITHUB_WORKSPACE/tests/acceptance/run.sh
steampipe service stop --force
create_release_tag:
name: Tag Release
needs: [run_acceptance_tests]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
- 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@v2
with:
ref: ${{ github.event.inputs.branch }}
- name: Unshallow
run: git fetch --prune --unshallow
- name: Unshallow
run: git fetch --prune --unshallow
- name: Tag Release
run: |
git config user.name "Steampipe GitHub Actions Bot"
git config user.email [email protected]
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
- name: Tag Release
run: |
git config user.name "Steampipe GitHub Actions Bot"
git config user.email [email protected]
git tag ${{ github.event.inputs.version }}
git push origin ${{ github.event.inputs.version }}
build_and_release_cli:
name: Release CLI
needs: [create_release_tag]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: ${{ github.event.inputs.branch }}
- 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@v2
with:
ref: ${{ github.event.inputs.version }}
- name: Unshallow
run: git fetch --prune --unshallow
- name: Unshallow
run: git fetch --prune --unshallow
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.17
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Setup GCloud
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS }}
project_id: ${{ env.PROJECT_ID }}
export_default_credentials: true
- name: Setup GCloud
uses: google-github-actions/[email protected]
with:
service_account_key: ${{ secrets.GCP_GITHUB_ACTION_PUSH_ARTIFACTS }}
project_id: ${{ env.PROJECT_ID }}
export_default_credentials: true
- name: Install GCloud Beta Components
run: |-
gcloud config list
gcloud components install beta
- name: Install GCloud Beta Components
run: |-
gcloud config list
gcloud components install beta
- name: Upload rpm and deb packages to artifact registry
run: |
gcloud beta artifacts yum upload steampipe-yum-repo --location=us --source=$GITHUB_WORKSPACE/dist/steampipe_linux_amd64.rpm --project steampipe
gcloud beta artifacts apt upload steampipe-apt-repo --location=us --source=$GITHUB_WORKSPACE/dist/steampipe_linux_amd64.deb --project steampipe
- name: Upload rpm and deb packages to artifact registry
run: |
gcloud beta artifacts yum upload steampipe-yum-repo --location=us --source=$GITHUB_WORKSPACE/dist/steampipe_linux_amd64.rpm --project steampipe
gcloud beta artifacts apt upload steampipe-apt-repo --location=us --source=$GITHUB_WORKSPACE/dist/steampipe_linux_amd64.deb --project steampipe
clean_up:
# let's clean up the artifacts.
@@ -389,12 +467,12 @@ jobs:
needs: build_and_release_cli
runs-on: ubuntu-latest
steps:
- name: Clean up Linux Build
uses: geekyeggo/delete-artifact@v1
with:
name: build-artifact-linux
- name: Clean up Linux Build
uses: geekyeggo/delete-artifact@v1
with:
name: build-artifact-linux
- name: Clean up Darwin Build
uses: geekyeggo/delete-artifact@v1
with:
name: build-artifact-darwin
- name: Clean up Darwin Build
uses: geekyeggo/delete-artifact@v1
with:
name: build-artifact-darwin