forked from knative-extensions/backstage-plugins
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Workflow to release midstream plugin (#10)
* Fix build (#59) Signed-off-by: Ali Ok <aliok@redhat.com> (cherry picked from commit 918c58f) * Workflow to release midstream plugin Signed-off-by: Ali Ok <aliok@redhat.com> * Workflow to release midstream plugin Signed-off-by: Ali Ok <aliok@redhat.com> * Workflow to release midstream plugin Signed-off-by: Ali Ok <aliok@redhat.com> * Address some comments Signed-off-by: Ali Ok <aliok@redhat.com> * Hacks to increment patch version Signed-off-by: Ali Ok <aliok@redhat.com> * Install specific go version Signed-off-by: Ali Ok <aliok@redhat.com> --------- Signed-off-by: Ali Ok <aliok@redhat.com>
- Loading branch information
Showing
5 changed files
with
174 additions
and
33 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
name: Backstage knative-event-mesh-backend | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- 'release-*' | ||
paths: | ||
- 'backstage/plugins/knative-event-mesh-backend/**' | ||
push: | ||
branches: | ||
- 'release-*' | ||
paths: | ||
- 'backstage/plugins/knative-event-mesh-backend/**' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write # allow GITHUB_TOKEN to publish packages | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Golang | ||
uses: actions/setup-go@v5 | ||
with: | ||
go-version: '>=1.21.1' # from https://github.com/openshift-knative/hack/blob/main/go.mod#L3 | ||
|
||
- name: Setup release name for release branch push | ||
if: github.event_name == 'push' | ||
run: | | ||
BRANCH=$(git rev-parse --abbrev-ref HEAD) #e.g. release-v1.33 | ||
echo "Release branch: ${BRANCH}" | ||
GO111MODULE=off go get -u github.com/openshift-knative/hack/cmd/sobranch | ||
SO_RELEASE_NAME=$( $(go env GOPATH)/bin/sobranch --upstream-version "${BRANCH}") # input format: "release-v1.11" or "release-1.11" or "v1.11" or "1.11" | ||
# SO_RELEASE_NAME will be something like "release-1.33" | ||
echo "SO_RELEASE_NAME: ${SO_RELEASE_NAME}" | ||
# split the release name to get the version number | ||
## e.g. release-1.33 -> 1.33 | ||
BASE_RELEASE_VERSION=${SO_RELEASE_NAME#*-} | ||
echo "BASE_RELEASE_VERSION: ${BASE_RELEASE_VERSION}" | ||
RELEASE_NAME="${BASE_RELEASE_VERSION}.0" | ||
# get the patch release versions for the BASE_RELEASE_VERSION | ||
# if there's one already, increase its number by 1 | ||
PATCH_RELEASES=$(npm view @openshift-knative/plugin-knative-event-mesh-backend versions --json | grep ${BASE_RELEASE_VERSION}) | ||
echo "Existing PATCH_RELEASES: ${PATCH_RELEASES}" | ||
if [ -z "${PATCH_RELEASES}" ]; then | ||
echo "No existing PATCH_RELEASES found for ${BASE_RELEASE_VERSION}" | ||
else | ||
echo "Existing PATCH_RELEASES found for ${BASE_RELEASE_VERSION}" | ||
PATCH=$(echo "${PATCH_RELEASES}" | tail -1 | tr -d '"' | awk -F \. '{print $3+1}') | ||
RELEASE_NAME="${BASE_RELEASE_VERSION}.${PATCH}" | ||
fi | ||
echo "RELEASE_NAME: ${RELEASE_NAME}" | ||
echo "RELEASE_NAME=${RELEASE_NAME}" >> $GITHUB_ENV | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version-file: 'backstage/.nvmrc' | ||
cache: 'yarn' | ||
cache-dependency-path: 'backstage/yarn.lock' | ||
|
||
- name: Print environment | ||
run: | | ||
node --version | ||
yarn --version | ||
- name: Install dependencies | ||
shell: bash | ||
working-directory: ./backstage | ||
run: yarn --prefer-offline --frozen-lockfile | ||
|
||
- name: Install tooling | ||
shell: bash | ||
working-directory: ./backstage | ||
run: npm install @backstage/cli -g | ||
|
||
- name: Run tests | ||
shell: bash | ||
working-directory: ./backstage | ||
run: | | ||
export PATH="./node_modules/.bin/:$PATH" | ||
yarn test | ||
- name: Build | ||
shell: bash | ||
working-directory: ./backstage | ||
run: | | ||
export PATH="./node_modules/.bin/:$PATH" | ||
yarn tsc | ||
yarn build:all | ||
- name: Update version of knative-event-mesh-backend plugin | ||
if: github.event_name == 'push' | ||
shell: bash | ||
working-directory: ./backstage/plugins/knative-event-mesh-backend | ||
run: | | ||
export PATH="./node_modules/.bin/:$PATH" | ||
yarn version --new-version ${RELEASE_NAME} --no-git-tag-version | ||
- name: Prepack knative-event-mesh-backend plugin | ||
shell: bash | ||
working-directory: ./backstage/plugins/knative-event-mesh-backend | ||
run: | | ||
export PATH="./node_modules/.bin/:$PATH" | ||
yarn prepack | ||
- name: Publish knative-event-mesh-backend plugin | ||
uses: JS-DevTools/npm-publish@v3 | ||
if: github.event_name == 'push' | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
access: public | ||
package: backstage/plugins/knative-event-mesh-backend | ||
registry: "https://npm.pkg.github.com" | ||
tag: latest | ||
|
||
- name: Postpack knative-event-mesh-backend plugin | ||
shell: bash | ||
working-directory: ./backstage/plugins/knative-event-mesh-backend | ||
run: | | ||
export PATH="./node_modules/.bin/:$PATH" | ||
yarn postpack |
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
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
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
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