Skip to content

Commit

Permalink
Publish plugin to @weaveworksoss/backstage-plugin-flux (#6)
Browse files Browse the repository at this point in the history
* Publish plugin to @weaveworksoss/backstage-plugin-flux

- @weaveworks doesn't work right now as npm cannot handle per-package
  scope and it conflicts with the github npm registry that hosts the
  @weaveworks/weave-gitops dependency
- Move the `private: true` up to the top to keep npm/yarn happy when
  publishing, this seems to be a yarn/npm workplace constraint
* Adds release instructions
* adds test/build/lint ci too
* Adds example .npmrc for publishing manually
* Fix more linting errors now that its switched on in CI
* Move license to just cover the plugin
- Include it in bundle too
  • Loading branch information
foot committed Jun 30, 2023
1 parent c6f3ed5 commit e8a4ac0
Show file tree
Hide file tree
Showing 26 changed files with 544 additions and 89 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: CI

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: ubuntu-latest
env:
# for @weaveworks/weave-gitops which is on github npm packages
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: '16.x'
- run: yarn install
- run: yarn lint
- run: yarn tsc
- run: yarn test
- run: yarn build:all
21 changes: 21 additions & 0 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Publish Package to npmjs
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '16.x'
registry-url: 'https://registry.npmjs.org'
scope: '@weaveworksoss'
- run: |
cd plugins/backstage-plugin-flux
yarn install --frozen-lockfile
./publish
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 0 additions & 2 deletions .npmrc

This file was deleted.

24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# [Backstage](https://backstage.io)

This is your newly scaffolded Backstage App, Good Luck!
## Local dev

For local dev we'll need to set up a Github OAuth app and a local kubernetes cluster.

## Configure Github OAuth
### Configure Github OAuth

Follow the [Backstage instructions to create a Github OAuth app](https://backstage.io/docs/auth/github/provider#create-an-oauth-app-on-github), relevant bit here:

Expand All @@ -14,7 +14,7 @@ Follow the [Backstage instructions to create a Github OAuth app](https://backsta
> - **Homepage URL**: http://localhost:3000
> - **Authorization callback URL**: http://localhost:7007/api/auth/github/handler/frame
Save the clientId and clientSecret that Github generates into a `.env` file or your `~/.bashrc` / `~/.zshrc`:
Save the **clientId** and **clientSecret** that Github generates into a `.env` file or your `~/.bashrc` / `~/.zshrc`:

```bash
export AUTH_GITHUB_CLIENT_ID=abc123
Expand All @@ -23,7 +23,7 @@ export AUTH_GITHUB_CLIENT_SECRET=abc123

They're referenced in the `app-config.kubernetes.yaml` file.

## Start a local kubernetes cluster
### Start a local kubernetes cluster

To start the app, run:

Expand All @@ -47,3 +47,19 @@ cp ./app-config.kubernetes.yaml ./app-config.local.yaml
# start the app, configuring backstage to use serviceaccount in ./demo
./startup.sh
```

## Releasing

Publishing a **GitHub release** will trigger a GitHub Action to build and push the npm module to the [backstage-plugin-flux npm package](https://www.npmjs.com/package/@weaveworksoss/backstage-plugin-flux).

### Create the release

Create a [new Github release](https://github.com/weaveworks/weaveworks-backstage/releases/new)

1. Click "Choose a tag" and type in the tag that the release should create on publish (e.g. `v0.5.0`)
2. Click **Generate release notes**
3. Click **Publish release**

After a few minutes the release should be available on npm.

Follow the [backstage-plugin-flux installation instructions](./plugins/backstage-plugin-flux/README.md) to upgrade the plugin in your Backstage app.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "root",
"version": "1.0.0",
"license": "Apache-2.0",
"private": true,
"engines": {
"node": "16 || 18"
Expand Down
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@backstage/plugin-techdocs-react": "^1.1.6",
"@backstage/plugin-user-settings": "^0.7.3",
"@backstage/theme": "^0.3.0",
"@weaveworks/backstage-plugin-flux": "^0.1.0",
"@weaveworksoss/backstage-plugin-flux": "^0.1.0",
"@material-ui/core": "^4.12.2",
"@material-ui/icons": "^4.9.1",
"history": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { AppRouter, FlatRoutes } from '@backstage/core-app-api';
import { CatalogGraphPage } from '@backstage/plugin-catalog-graph';
import { RequirePermission } from '@backstage/plugin-permission-react';
import { catalogEntityCreatePermission } from '@backstage/plugin-catalog-common/alpha';
import { FluxEntityHelmReleasesCard } from '@weaveworks/backstage-plugin-flux';
import { FluxEntityHelmReleasesCard } from '@weaveworksoss/backstage-plugin-flux';

const app = createApp({
components: {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/components/catalog/EntityPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ import {
import { TechDocsAddons } from '@backstage/plugin-techdocs-react';
import { ReportIssue } from '@backstage/plugin-techdocs-module-addons-contrib';
import { EntityKubernetesContent } from '@backstage/plugin-kubernetes';
import { FluxEntityHelmReleasesCard } from '@weaveworks/backstage-plugin-flux';
import { FluxEntityHelmReleasesCard } from '@weaveworksoss/backstage-plugin-flux';

const techdocsContent = (
<EntityTechdocsContent>
Expand Down
4 changes: 4 additions & 0 deletions plugins/backstage-plugin-flux/.npmrc.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//registry.npmjs.org/:_authToken=${NPM_TOKEN}
registry=https://registry.npmjs.org/
always-auth=true

Loading

0 comments on commit e8a4ac0

Please sign in to comment.