STAC-22210 Update checks #154
Workflow file for this run
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: Pipeline | |
on: | |
pull_request: | |
paths-ignore: | |
- "**.md" | |
- "!.changeset/**" | |
push: | |
branches: | |
# latest release | |
- main | |
# maintenance releases | |
- v[0-9]+.x.x | |
- v[0-9]+.[0-9]+.x | |
env: | |
CI: true | |
HELM_CHART_BRANCH: gh-pages | |
jobs: | |
checks: | |
name: Checks | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
with: | |
# changesets status requires deeper history | |
fetch-depth: 0 | |
- name: Setup environment | |
uses: ./.github/actions/setup-env | |
- name: Check for Uncommitted Changes | |
run: | | |
git diff --name-only --exit-code --relative || (echo "\nUncommitted changes found π" && exit 1) | |
- name: Read Changeset Status | |
id: changeset-status | |
if: github.event_name == 'pull_request' | |
uses: ./.github/actions/changeset-status | |
with: | |
args: --since origin/${{ github.base_ref }} | |
- name: Check Version Changes | |
if: steps.changeset-status.outputs.type | |
run: | | |
BASE_BRANCH="${{ steps.changeset-status.outputs.base_branch }}" | |
VERSION_TYPE="${{ steps.changeset-status.outputs.type }}" | |
# Check for invalid version bumps based on the branch type | |
if [[ "$BASE_BRANCH" =~ ^v[0-9]+\.[0-9]+\.x$ && "$VERSION_TYPE" != "patch" ]]; then | |
echo "π¨ Detected '$VERSION_TYPE' bump." | |
echo "π¨ Only 'patch' versions are allowed for the maintenance branch $BASE_BRANCH." | |
exit 1 | |
fi | |
if [[ "$BASE_BRANCH" =~ ^v[0-9]+\.x\.x$ && "$VERSION_TYPE" == "major" ]]; then | |
echo "π¨ Detected '$VERSION_TYPE' bump." | |
echo "π¨ Only 'patch' or 'minor' versions are allowed for the maintenance branch $BASE_BRANCH." | |
exit 1 | |
fi | |
echo "β Detected '$VERSION_TYPE' bump." | |
- name: Run typecheck | |
run: yarn typecheck | |
- name: Run lint | |
run: yarn lint . | |
- name: Build Observability Package | |
run: yarn build-pkg observability | |
build: | |
name: Build and Version | |
runs-on: ubuntu-latest | |
# runs only on pushes so it does not run on PRs | |
if: github.event_name == 'push' | |
outputs: | |
tagged_release: ${{ steps.release-info.outputs.tag }} | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
# changesets status requires deeper history | |
fetch-depth: 0 | |
- name: Setup environment | |
uses: ./.github/actions/setup-env | |
- name: Read Changeset Status | |
id: changeset-status | |
uses: ./.github/actions/changeset-status | |
- name: Check if Version Already Exists | |
if: steps.changeset-status.outputs.new_version | |
run: | | |
NAME="${{ steps.changeset-status.outputs.name }}" | |
NEW_VERSION="${{ steps.changeset-status.outputs.new_version }}" | |
# Check that a tag for the new version does not already exist | |
if [[ ! -z $(git tag -l "$NAME@$NEW_VERSION") ]]; then | |
echo "π¨ The version '$NAME@$NEW_VERSION' already exists." | |
echo "π¨ Please ensure that the version bump and the base branch is correct." | |
exit 1 | |
fi | |
# creates a PR if there are changesets or assign the new tag if the PR is merged | |
- name: Create Release Pull Request or Publish | |
id: changesets | |
# runs only when the changeset's base_branch is the target branch | |
if: steps.changeset-status.outputs.base_branch == '${{ github.ref_name }}' | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
MESSAGE: "π Release `${{ steps.changeset-status.outputs.name }}@${{ steps.changeset-status.outputs.old_version }} β ${{ steps.changeset-status.outputs.new_version }}`" | |
uses: changesets/action@v1 | |
with: | |
title: ${{ env.MESSAGE }} | |
commit: ${{ env.MESSAGE }} | |
# define the publish command, so changeset creates a release in GitHub | |
publish: yarn release-tag | |
- name: Extract Release Info | |
id: release-info | |
if: steps.changesets.outputs.published == 'true' | |
# extract the first package name and version and format as `name-version` | |
# the publish-pkgs script expects `name-version` but not `name@version` | |
# so `release-tag` creates both but outputs only the default changeset format | |
run: | | |
TAG=$(echo '${{ steps.changesets.outputs.publishedPackages }}' | jq -r '.[0] | "\(.name)-\(.version)"') | |
echo "tag=$TAG" >> $GITHUB_OUTPUT | |
- name: Preare Build Artifact | |
id: prepare-artifact | |
if: steps.release-info.outputs.tag | |
run: | | |
yarn publish-pkgs \ | |
-s "${{ github.repository }}" \ | |
-b "${{ env.HELM_CHART_BRANCH }}" \ | |
-t "${{ steps.release-info.outputs.tag }}" | |
- name: Upload Charts Artifact | |
if: steps.prepare-artifact.conclusion == 'success' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: charts | |
path: tmp | |
if-no-files-found: error | |
release: | |
name: Helm Release | |
needs: | |
- build | |
- checks | |
if: needs.build.outputs.tagged_release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Target Branch | |
uses: actions/checkout@v4 | |
with: | |
ref: "${{ env.HELM_CHART_BRANCH }}" | |
- name: Configure Git User | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
- name: Set Up Helm CLI | |
uses: azure/setup-helm@v3 | |
with: | |
version: v3.8.0 | |
- name: Download Build Artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: charts | |
- name: Commit and Push Changes | |
run: | | |
git add ./{assets,charts,extensions,index.yaml} | |
git commit -m "CI: Publish Helm charts for ${{ needs.build.outputs.tagged_release }}" | |
git push | |
- name: Run Helm Chart Releaser | |
uses: helm/[email protected] | |
with: | |
charts_dir: ./charts/* | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_SKIP_EXISTING: true |