Skip to content

Commit

Permalink
Release workflow
Browse files Browse the repository at this point in the history
Signed-off-by: Ali Ok <aliok@redhat.com>
  • Loading branch information
aliok committed May 13, 2024
1 parent 0255e5b commit e0b0868
Showing 1 changed file with 25 additions and 15 deletions.
40 changes: 25 additions & 15 deletions .github/workflows/release-plugins.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: read
packages: write # allow GITHUB_TOKEN to publish packages

steps:
- name: Checkout
Expand All @@ -34,27 +31,41 @@ jobs:
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
cd /tmp
git clone https://github.com/openshift-knative/hack.git
cd hack
go install ./cmd/sobranch
cd -
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}"
EXISTING_RELEASES=""
if EXISTING_RELEASES=$(npm view @openshift-knative/plugin-knative-event-mesh-backend versions --json); then
echo "Package information fetched successfully"
echo "Existing releases: ${EXISTING_RELEASES}"
PATCH_RELEASES=$(echo "${EXISTING_RELEASES}" | grep ${BASE_RELEASE_VERSION})
if [ -z "${PATCH_RELEASES}" ]; then
echo "No existing PATCH_RELEASES found for ${BASE_RELEASE_VERSION}"
echo "Going to publish a new .0 patch release"
RELEASE_NAME="${BASE_RELEASE_VERSION}.0"
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
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}"
echo "Error fetching package information. Going to publish a new .0 patch release"
RELEASE_NAME="${BASE_RELEASE_VERSION}.0"
fi
echo "RELEASE_NAME: ${RELEASE_NAME}"
Expand Down Expand Up @@ -116,10 +127,9 @@ jobs:
uses: JS-DevTools/npm-publish@v3
if: github.event_name == 'push'
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.NPM_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
Expand Down

0 comments on commit e0b0868

Please sign in to comment.