01 - Powerpipe: Prerelease #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: "01 - Powerpipe: Prerelease" | |
on: | |
workflow_dispatch: | |
inputs: | |
pre_release_identifier: | |
type: choice | |
description: "Select Pre-Release Identifier" | |
options: | |
- alpha | |
- beta | |
- rc | |
required: true | |
env: | |
PROJECT_ID: steampipe | |
ORG: turbot | |
CORE_REPO: us-docker.pkg.dev/steampipe/steampipe | |
ASSET_IMAGE_NAME: assets | |
GH_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }} | |
jobs: | |
acceptance_tests: | |
name: Run Acceptance Tests | |
uses: turbot/powerpipe/.github/workflows/11-test-acceptance.yaml@main | |
build_assets: | |
name: Build and Release Dashboard Assets | |
needs: [acceptance_tests] | |
runs-on: ubuntu-latest | |
outputs: | |
version: ${{ steps.set_version.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: powerpipe | |
ref: ${{ github.event.ref }} | |
- name: Calculate version | |
id: calculate_version | |
run: | | |
VERSION_JSON=$(cat powerpipe/version.json) | |
MAJOR=$(echo $VERSION_JSON | jq '.major') | |
MINOR=$(echo $VERSION_JSON | jq '.minor') | |
PATCH=$(echo $VERSION_JSON | jq '.patch') | |
VERSION="v$MAJOR.$MINOR.$PATCH" | |
if [ "${{ github.event.inputs.pre_release_identifier }}" = "alpha" ]; then | |
echo "VERSION=${VERSION}-alpha.$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV | |
elif [ "${{ github.event.inputs.pre_release_identifier }}" = "beta" ]; then | |
echo "VERSION=${VERSION}-beta.$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV | |
elif [ "${{ github.event.inputs.pre_release_identifier }}" = "rc" ]; then | |
echo "VERSION=${VERSION}-rc.$(date +'%Y%m%d%H%M')" >> $GITHUB_ENV | |
fi | |
- name: Set VERSION as output | |
run: echo "::set-output name=version::$VERSION" | |
id: set_version | |
- 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: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ">=18.12.0" | |
- name: Setup Yarn | |
working-directory: ./powerpipe/ui/dashboard | |
run: |- | |
rm -rf ./build | |
# Cache node modules to speed up builds | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v4 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
- name: YARN Install | |
working-directory: ./powerpipe/ui/dashboard | |
run: |- | |
unset CI | |
yarn install | |
- name: Generate dashboard UI icons | |
working-directory: ./powerpipe/ui/dashboard | |
run: |- | |
make setup-icons | |
- name: Run Unit Tests | |
working-directory: ./powerpipe/ui/dashboard | |
run: | | |
yarn install | |
CI=true yarn test | |
- name: YARN Build | |
working-directory: ./powerpipe/ui/dashboard | |
run: |- | |
unset CI | |
yarn build | |
env: | |
REACT_APP_HEAP_ID: ${{ secrets.HEAP_ANALYTICS_PRODUCTION_ID }} | |
REACT_APP_VERSION: ${{ env.VERSION }} | |
- name: Move Build Assets | |
run: |- | |
mkdir -p dashboard_ui_build | |
mv ./powerpipe/ui/dashboard/build/* dashboard_ui_build/ | |
ls -la dashboard_ui_build | |
- name: Create a version file | |
run: |- | |
JSON_STRING=$( jq -n \ | |
--arg version "$VERSION" \ | |
'{ | |
"version":$version, | |
}' ) | |
echo $JSON_STRING > ./dashboard_ui_build/version.json | |
- name: Archive built dashboard assets | |
run: | | |
cd dashboard_ui_build | |
tar -czvf ../dashboard_ui_assets.tar.gz * | |
- name: Upload dashboard assets artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dashboard-ui-assets-archive | |
path: dashboard_ui_assets.tar.gz | |
build_and_release: | |
name: Build and Release Powerpipe | |
needs: [build_assets] | |
runs-on: ubuntu-latest | |
env: | |
VERSION: ${{ needs.build_assets.outputs.version }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: powerpipe | |
ref: ${{ github.event.ref }} | |
- name: Checkout Pipe Fittings Components repository | |
uses: actions/checkout@v4 | |
with: | |
repository: turbot/pipe-fittings | |
path: pipe-fittings | |
- name: Tag Release | |
run: | | |
cd powerpipe | |
git config user.name "Powerpipe GitHub Actions Bot" | |
git config user.email [email protected] | |
git tag $VERSION | |
git push origin $VERSION | |
# this is required, check golangci-lint-action docs | |
- uses: actions/setup-go@v5 | |
with: | |
go-version: "1.21" | |
cache: false # setup-go v4 caches by default, do not change this parameter, check golangci-lint-action doc: https://github.com/golangci/golangci-lint-action/pull/704 | |
- name: Download Dashboard UI Assets Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: dashboard-ui-assets-archive | |
path: powerpipe/internal/dashboardassets | |
- name: Check assets location | |
run: | | |
ls -la powerpipe/internal/dashboardassets | |
mv powerpipe/internal/dashboardassets/dashboard_ui_assets.tar.gz powerpipe/internal/dashboardassets/assets.tar.gz | |
ls -la powerpipe/internal/dashboardassets | |
- name: Setup release environment | |
run: |- | |
cd powerpipe | |
echo 'GITHUB_TOKEN=${{secrets.GH_ACCESS_TOKEN}}' > .release-env | |
- name: Release publish | |
run: |- | |
cd powerpipe | |
make release |