Skip to content

Commit

Permalink
@backstage-community/plugin-catalog-backend-module-scaffolder-relatio…
Browse files Browse the repository at this point in the history
[email protected]

* ci(release_workspace): pass through environment variable
* ci(ci): change fetch-depth
* handle no github event
* delete changeset

Signed-off-by: Beth Griggs <[email protected]>
  • Loading branch information
BethGriggs committed Sep 4, 2024
1 parent 8288c9c commit 33e3726
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
# Needed for diff
fetch-depth: ${{ env.NUMBER_OF_COMMITS }}
fetch-depth: 100

- name: Set up Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
Expand Down
50 changes: 45 additions & 5 deletions .github/workflows/release_workspace.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ on:
description: "Force release even if no changesets are present"
required: false
type: boolean
branch:
description: "Branch to run the workflow on"
required: false
default: "main"
type: string
workflow_call:
inputs:
force_release:
Expand All @@ -21,13 +26,18 @@ on:
description: "Name of the Workspace"
required: true
type: string
branch:
description: "Branch to run the workflow on"
required: false
default: "main"
type: string

concurrency:
group: ${{ github.workflow }}-${{ inputs.workspace }}

jobs:
changesets-pr:
name: Update Version Packages PR for ${{ inputs.workspace }}
name: Update Version Packages PR for ${{ inputs.workspace }} on branch ${{ inputs.branch }}
runs-on: ubuntu-latest
defaults:
run:
Expand All @@ -40,6 +50,8 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
ref: ${{ inputs.branch }}
- name: Set up Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
Expand All @@ -62,13 +74,24 @@ jobs:
run: yarn install --immutable

- name: Fetch previous commit for release check
run: git fetch origin '${{ github.event.before }}'
if: ${{ github.event.before != '' }}
run: git fetch origin '${{ github.event.before }}

- name: Fetch the commit that triggered the workflow (used by backstage/changesets-action)
run: git fetch origin ${{ github.sha }}
continue-on-error: true

- name: Check if release
id: release_check
if: inputs.force_release != true
run: node ../../scripts/ci/check-if-release.js
run: |
COMMIT_SHA_BEFORE=${{ github.event.before }}
if [ -z "$COMMIT_SHA_BEFORE" ]; then
COMMIT_SHA_BEFORE=$(git rev-list --max-parents=0 HEAD)
fi
node ../../scripts/ci/check-if-release.js
env:
TARGET_BRANCH: ${{ inputs.branch }}
WORKSPACE_NAME: ${{ inputs.workspace }}
COMMIT_SHA_BEFORE: '${{ github.event.before }}'

Expand All @@ -88,7 +111,7 @@ jobs:


release:
name: Release workspace ${{ inputs.workspace }}
name: Release workspace ${{ inputs.workspace }} on branch ${{ inputs.branch }}
runs-on: ubuntu-latest
needs: changesets-pr
if: needs.changesets-pr.outputs.needs_release == 'true' || inputs.force_release == true
Expand All @@ -100,8 +123,16 @@ jobs:
NODE_OPTIONS: --max-old-space-size=4096

steps:
- name: Ensure branch name follows the 'workspace/{workspace}' pattern if not on 'main'
run: |
if [ "${{ inputs.branch }}" != "main" ] && [[ "${{ inputs.branch }}" != "workspace/${{ inputs.workspace }}" ]]; then
echo "Branch name '${{ inputs.branch }}' does not follow the expected pattern 'workspace/${{ inputs.workspace }}'."
exit 1
fi
- name: Checkout
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
ref: ${{ inputs.branch }}
- name: Set up Node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4
with:
Expand Down Expand Up @@ -132,10 +163,19 @@ jobs:
- name: Build all packages
run: yarn build:all

- name: Determine npm publish tag (latest or maintenance)
id: determine-tag
run: |
if [ "${{ inputs.branch }}" = "main" ]; then
echo "tag=latest" >> $GITHUB_OUTPUT
else
echo "tag=maintenance" >> $GITHUB_OUTPUT
fi
- name: publish
run: |
yarn config set -H 'npmAuthToken' "${{secrets.NPM_TOKEN}}"
yarn workspaces foreach -v --no-private npm publish --access public --tolerate-republish
yarn workspaces foreach -v --no-private npm publish --access public --tolerate-republish --tag ${{ steps.determine-tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor': patch
---

This release is equivalent to 1.0.0.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor",
"description": "The scaffolder-relation-processor backend module for the catalog plugin.",
"version": "1.2.0",
"version": "1.0.0",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
Expand Down

0 comments on commit 33e3726

Please sign in to comment.