Verify the version bump against the base branch | v0.2.x #116
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: | |
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: Detect File Changes | |
id: changed-files | |
uses: tj-actions/changed-files@v41 | |
with: | |
files_yaml: | | |
eslint_config: | |
- .eslintrc.js | |
- .eslintignore | |
- yarn.lock | |
eslint_target: | |
- '**/*.{ts,js,vue}' | |
- name: Lint all files | |
if: ${{ github.event_name == 'push' || steps.changed-files.outputs.eslint_config_any_changed == 'true' }} | |
run: yarn lint . | |
- name: Lint changed files | |
if: ${{ steps.lint-all.outcome == 'skipped' && steps.changed-files.outputs.eslint_target_any_changed == 'true' }} | |
run: yarn lint ${{ steps.changed-files.outputs.eslint_target_all_changed_files }} --no-error-on-unmatched-pattern | |
- 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: | |
fetch-depth: 0 | |
- name: Setup environment | |
uses: ./.github/actions/setup-env | |
- name: Read Changeset Status | |
id: changeset-status | |
uses: ./.github/actions/changeset-status | |
# 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="${{ steps.changeset-status.outputs.name }}-${{ steps.changeset-status.outputs.new_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@v3 | |
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@v3 | |
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/chart-releaser-action@v1.4.1 | |
with: | |
charts_dir: ./charts/* | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
CR_SKIP_EXISTING: true |