Skip to content

Commit

Permalink
Release setup (#13)
Browse files Browse the repository at this point in the history
* Release setup for backend

Signed-off-by: Ali Ok <aliok@redhat.com>

* Release setup for plugins

Signed-off-by: Ali Ok <aliok@redhat.com>

* Fix NPM publish

Signed-off-by: Ali Ok <aliok@redhat.com>

* Switch plugin `main` version to 0.0.0-nightly

Signed-off-by: Ali Ok <aliok@redhat.com>

* Set release version of NPM package to GitHub release name

Signed-off-by: Ali Ok <aliok@redhat.com>

* Allow passing release name to the manual workflow dispatch

Signed-off-by: Ali Ok <aliok@redhat.com>

---------

Signed-off-by: Ali Ok <aliok@redhat.com>
  • Loading branch information
aliok authored Jan 2, 2024
1 parent 69f9a66 commit 6d300aa
Show file tree
Hide file tree
Showing 9 changed files with 181 additions and 8 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/backstage-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Publish release on NPM

on:
# When manually triggered
workflow_dispatch:
inputs:
releaseName:
description: 'Release name, e.g. v1.2.3'
required: true

# When there's a release created
release:
types: [ published ]

jobs:
publish-release-on-npm:
name: Publish release on NPM
runs-on: ubuntu-latest

steps:
- name: Setup release name
run: |
if [ -z "${{ github.event.release.name }}" ]; then
echo "RELEASE_NAME=${{ github.event.inputs.releaseName }}" >> $GITHUB_ENV
else
echo "RELEASE_NAME=${{ github.event.release.name }}" >> $GITHUB_ENV
fi
- name: Checkout
uses: actions/checkout@v4

- 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: Print release name
run: |
echo "Release name: ${RELEASE_NAME}"
- 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
- name: Update version of knative-event-mesh-backend plugin
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: Publish knative-event-mesh-backend plugin
uses: JS-DevTools/npm-publish@v2
with:
token: ${{ secrets.NPM_TOKEN }}
access: public
package: backstage/plugins/knative-event-mesh-backend
9 changes: 6 additions & 3 deletions .github/workflows/backstage-unit-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Backstage unit tests

on:
push:
branches:
- main
pull_request:
branches:
- main
Expand All @@ -12,6 +9,7 @@ jobs:
unit-tests:
name: Test
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -23,6 +21,11 @@ jobs:
cache: 'yarn'
cache-dependency-path: 'backstage/yarn.lock'

- name: Print environment
run: |
node --version
yarn --version
- name: Install dependencies
shell: bash
working-directory: ./backstage
Expand Down
2 changes: 1 addition & 1 deletion backstage/lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*", "plugins/*"],
"npmClient": "yarn",
"version": "0.1.0",
"version": "0.0.0-nightly",
"$schema": "node_modules/lerna/schemas/lerna-schema.json"
}
2 changes: 1 addition & 1 deletion backstage/packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"@backstage/plugin-search-backend-module-techdocs": "^0.1.11",
"@backstage/plugin-search-backend-node": "^1.2.11",
"@backstage/plugin-techdocs-backend": "^1.9.0",
"@knative-extensions/plugin-knative-event-mesh-backend": "^0.1.0",
"@knative-extensions/plugin-knative-event-mesh-backend": "0.0.0-nightly",
"app": "link:../app",
"better-sqlite3": "^9.0.0",
"dockerode": "^3.3.1",
Expand Down
4 changes: 4 additions & 0 deletions backstage/plugins/knative-event-mesh-backend/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# keep this file so that npm doesn't use the .gitignore file
src/
.eslintrc.js
app-config.yaml
4 changes: 2 additions & 2 deletions backstage/plugins/knative-event-mesh-backend/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "@knative-extensions/plugin-knative-event-mesh-backend",
"version": "0.1.0",
"version": "0.0.0-nightly",
"main": "src/index.ts",
"types": "src/index.ts",
"license": "Apache-2.0",
"private": true,
"private": false,
"publishConfig": {
"access": "public",
"main": "dist/index.cjs.js",
Expand Down
2 changes: 1 addition & 1 deletion backstage/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7831,7 +7831,7 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==

"@types/react-dom@*", "@types/react-dom@<18.0.0":
"@types/react-dom@*", "@types/react-dom@<18.0.0", "@types/react-dom@^17":
version "17.0.25"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.25.tgz#e0e5b3571e1069625b3a3da2b279379aa33a0cb5"
integrity sha512-urx7A7UxkZQmThYA4So0NelOVjx3V4rNFVJwp0WZlbIK5eM4rNJDiN3R/E9ix0MBh6kAEojk/9YL+Te6D9zHNA==
Expand Down
52 changes: 52 additions & 0 deletions hack/release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env bash

# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Documentation about this script and how to use it can be found
# at https://github.com/knative/test-infra/tree/master/ci

source $(dirname $0)/../vendor/knative.dev/hack/release.sh

export GO111MODULE=on

# Yaml files to generate, and the source config dir for them.
declare -A COMPONENTS
COMPONENTS=(
["eventmesh.yaml"]="backends/config/100-eventmesh"
)
readonly COMPONENTS

function build_release() {
# Update release labels if this is a tagged release
if [[ -n "${TAG}" ]]; then
echo "Tagged release, updating release labels to app.kubernetes.io/version: \"${TAG}\""
LABEL_YAML_CMD=(sed -e "s|app.kubernetes.io/version: devel|app.kubernetes.io/version: \"${TAG}\"|")
else
echo "Untagged release, will NOT update release labels"
LABEL_YAML_CMD=(cat)
fi

local all_yamls=()
for yaml in "${!COMPONENTS[@]}"; do
local config="${COMPONENTS[${yaml}]}"
echo "Building Knative Backstage Backends - ${config}"
ko resolve -j 1 ${KO_FLAGS} -f ${config}/ | "${LABEL_YAML_CMD[@]}" > ${yaml}
all_yamls+=(${yaml})
done

ARTIFACTS_TO_PUBLISH="${all_yamls[@]}"
}

main $@
29 changes: 29 additions & 0 deletions test/presubmit-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env bash

# Copyright 2023 The Knative Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# This script runs the presubmit tests; it is started by prow for each PR.
# For convenience, it can also be executed manually.
# Running the script without parameters, or with the --all-tests
# flag, causes all tests to be executed, in the right order.
# Use the flags --build-tests, --unit-tests and --integration-tests
# to run a specific set of tests.

export GO111MODULE=on
export DISABLE_MD_LINTING=1

source $(dirname "$0")/../vendor/knative.dev/hack/presubmit-tests.sh

main $@

0 comments on commit 6d300aa

Please sign in to comment.