Skip to content

Commit

Permalink
Backport #60 (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
owanturist authored Jan 15, 2025
1 parent c80abfb commit 1cc7ec9
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 123 deletions.
26 changes: 18 additions & 8 deletions .github/actions/changeset-status/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,22 @@ runs:
fi
echo "✅ Temporary file created at: $OUTPUT"
# Run the changeset status command with relative path output
yarn changeset status ${{ inputs.args }} --output $(realpath --relative-to . "$OUTPUT")
RELATED_OUTPUT=$(realpath --relative-to . "$OUTPUT")
if [ ! -s "$OUTPUT" ]; then
echo "🚨 Error: Temporary file is empty after running 'yarn changeset status'"
exit 1
fi
# Run the changeset status command with relative path output
# and catch an error if the command fails
{ # try
CAUGHT_OUTPUT=$(yarn changeset status ${{ inputs.args }} --output $RELATED_OUTPUT 2>&1)
} || { # catch
# If the error is NOT caused by empty changesets, print the error and exit
if ! echo "$CAUGHT_OUTPUT" | grep -q "Some packages have been changed but no changesets were found"; then
echo "$CAUGHT_OUTPUT" >&2
exit 1
fi
}
# if the .releases length is greater than 0, then the changeset is ready to be released
if jq -e '.releases | length > 0' "$OUTPUT" > /dev/null; then
# if the output is not empty and the .releases length is greater than 0, then the changeset is ready to be released
if [ -s "$OUTPUT" ] && jq -e '.releases | length > 0' "$OUTPUT" > /dev/null; then
NAME=$(jq -r '.releases[0].name' "$OUTPUT")
TYPE=$(jq -r '.releases[0].type' "$OUTPUT")
OLD_VERSION=$(jq -r '.releases[0].oldVersion' "$OUTPUT")
Expand All @@ -56,6 +62,10 @@ runs:
echo "type=$TYPE" >> $GITHUB_OUTPUT
echo "old_version=$OLD_VERSION" >> $GITHUB_OUTPUT
echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT
# print the github output
echo "📦 Changeset found:"
cat $GITHUB_OUTPUT
else
echo "⏩ No changeset found"
fi
Expand Down
38 changes: 19 additions & 19 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,11 @@ jobs:
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
- 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: Run typecheck
run: yarn typecheck

- 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: Run lint
run: yarn lint .

- name: Build Observability Package
run: yarn build-pkg observability
Expand All @@ -108,6 +95,19 @@ jobs:
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
Expand Down Expand Up @@ -144,7 +144,7 @@ jobs:
- name: Upload Charts Artifact
if: steps.prepare-artifact.conclusion == 'success'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: charts
path: tmp
Expand Down Expand Up @@ -174,7 +174,7 @@ jobs:
version: v3.8.0

- name: Download Build Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: charts

Expand Down
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,5 @@
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"typescript.tsdk": "node_modules/typescript/lib"
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"lint": "eslint --ext .ts,.js,.vue",
"dev": "NODE_ENV=dev vue-cli-service serve",
"build": "vue-cli-service build",
"typecheck": "yarn workspaces run typecheck",
"clean": "./node_modules/@rancher/shell/scripts/clean",
"build-pkg": "./node_modules/@rancher/shell/scripts/build-pkg.sh",
"serve-pkgs": "./node_modules/@rancher/shell/scripts/serve-pkgs",
Expand All @@ -31,6 +32,6 @@
"release-tag": "changeset tag && ./scripts/duplicate-release-tags.sh"
},
"devDependencies": {
"@changesets/cli": "^2.27.9"
"@changesets/cli": "^2.27.11"
}
}
1 change: 1 addition & 0 deletions pkg/observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
},
"icon": "https://raw.githubusercontent.com/stackvista/rancher-extension-stackstate/main/pkg/observability/rancher-observability.svg",
"scripts": {
"typecheck": "tsc --noEmit --skipLibCheck",
"dev": "./node_modules/.bin/nuxt dev",
"nuxt": "./node_modules/.bin/nuxt"
},
Expand Down
42 changes: 0 additions & 42 deletions tsconfig.json

This file was deleted.

Loading

0 comments on commit 1cc7ec9

Please sign in to comment.