Workflow to release midstream plugin #5
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: 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 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 |