Skip to content

Commit

Permalink
Merge pull request cockroachdb#91764 from nathanstilwell/cluster-publ…
Browse files Browse the repository at this point in the history
…ish-workflow-dry-run
  • Loading branch information
celiala authored Nov 15, 2022
2 parents 4660d3b + 92150e4 commit 1e59412
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 6 deletions.
21 changes: 18 additions & 3 deletions .github/workflows/cluster-ui-release-next.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- 'pkg/ui/workspaces/cluster-ui/**/*.tsx?'
- 'pkg/ui/workspaces/cluster-ui/yarn.lock'
- 'pkg/ui/workspaces/cluster-ui/package.json'

jobs:
publish_cluster_ui:
Expand Down Expand Up @@ -34,12 +35,26 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Check if version is published
id: version-check
shell: bash
run: |
PACKAGE_VERSION=$(cat ./pkg/ui/workspaces/cluster-ui/package.json | jq -r ".version");
VERSIONS=$(npm view @cockroachlabs/cluster-ui versions)
if [[ $VERSIONS == *"$PACKAGE_VERSION"* ]]; then
echo "published=yes" >> $GITHUB_OUTPUT
echo
echo "🛑 Cluster UI package version $PACKAGE_VERSION is already published"
echo "to npm. Publishing step should be skipped. 🛑"
else
echo "published=no" >> $GITHUB_OUTPUT
fi
- name: Build Cluster UI
run: |
yarn install --frozen-lockfile
bazel build //pkg/ui/workspaces/cluster-ui:cluster-ui
- name: Publish prerelease version
run: |
echo "yarn version --prerelease --preid prerelease"
echo "yarn publish --access public --tag next"
if: steps.version-check.outputs.published == 'no'
run: npm publish --access public --tag next --dry-run"
21 changes: 18 additions & 3 deletions .github/workflows/cluster-ui-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
paths:
- 'pkg/ui/workspaces/cluster-ui/**/*.tsx?'
- 'pkg/ui/workspaces/cluster-ui/yarn.lock'
- 'pkg/ui/workspaces/cluster-ui/package.json'

jobs:
publish_cluster_ui:
Expand Down Expand Up @@ -34,6 +35,21 @@ jobs:
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Check if version is published
id: version-check
shell: bash
run: |
PACKAGE_VERSION=$(cat ./pkg/ui/workspaces/cluster-ui/package.json | jq -r ".version");
VERSIONS=$(npm view @cockroachlabs/cluster-ui versions)
if [[ $VERSIONS == *"$PACKAGE_VERSION"* ]]; then
echo "published=yes" >> $GITHUB_OUTPUT
echo
echo "🛑 Cluster UI package version $PACKAGE_VERSION is already published"
echo "to npm. Publishing step should be skipped. 🛑"
else
echo "published=no" >> $GITHUB_OUTPUT
fi
- name: Get Branch name
shell: bash
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
Expand All @@ -45,6 +61,5 @@ jobs:
bazel build //pkg/ui/workspaces/cluster-ui:cluster-ui
- name: Publish patch version
run: |
echo "yarn version --patch"
echo "yarn publish --access public --tag ${{ steps.branch_name.outputs.branch }}"
if: steps.version-check.outputs.published == 'no'
run: npm publish --access public --tag ${{ steps.branch_name.outputs.branch }} --dry-run"

0 comments on commit 1e59412

Please sign in to comment.