Skip to content

Commit deac4f3

Browse files
committed
Set up CI for plugins
This will lint, test, and publish individual plugins.
1 parent f2b82a1 commit deac4f3

File tree

9 files changed

+177
-5
lines changed

9 files changed

+177
-5
lines changed

.github/workflows/publish.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish
2+
3+
# This workflow will publish releases published on GitHub to NPM.
4+
5+
on:
6+
release:
7+
types:
8+
- released
9+
workflow_dispatch:
10+
inputs:
11+
tag:
12+
description: The tag to publish (for example "coder/v0.0.0")
13+
type: string
14+
required: true
15+
16+
concurrency: ${{ github.workflow }}-${{ github.ref }}
17+
18+
jobs:
19+
npm:
20+
runs-on: ubuntu-latest
21+
steps:
22+
- uses: robinraju/release-downloader@v1.9
23+
with:
24+
tag: ${{ github.event.inputs.tag || github.ref_name }}
25+
fileName: "*.tgz"
26+
- run: yarn publish *.tgz
27+
env:
28+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

.github/workflows/release.yaml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Release
2+
3+
# This workflow will draft a release for a plugin when tagged.
4+
# The tag format is <name>/v<version> without the backstage-plugin- prefix.
5+
6+
on:
7+
push:
8+
tags:
9+
- "*/v*"
10+
11+
permissions:
12+
contents: write # For creating releases.
13+
14+
concurrency: ${{ github.workflow }}-${{ github.ref }}
15+
16+
jobs:
17+
split-tag:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
plugin: ${{ steps.split.outputs.plugin }}
21+
version: ${{ steps.split.outputs.version }}
22+
steps:
23+
- env:
24+
TAG: ${{ github.ref_name }}
25+
id: split
26+
run: |
27+
parts=(${TAG//\/v/ })
28+
echo "plugin=${parts[0]}" >> $GITHUB_OUTPUT
29+
echo "version=${parts[1]}" >> $GITHUB_OUTPUT
30+
plugin:
31+
needs: split-tag
32+
runs-on: ubuntu-latest
33+
defaults:
34+
run:
35+
working-directory: plugins/backstage-plugin-${{ needs.split-tag.outputs.plugin }}
36+
name: ${{ needs.split-tag.outputs.plugin }} v${{ needs.split-tag.outputs.version }}
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-node@v4
40+
with:
41+
node-version-file: .node-version
42+
cache: yarn
43+
- run: yarn install --frozen-lockfile
44+
- run: yarn lint
45+
- run: yarn tsc
46+
- run: yarn test
47+
- run: yarn build
48+
# Version it with the version in the tag and upload it to a draft release.
49+
- run: yarn version --new-version ${{ needs.split-tag.outputs.version }}
50+
- run: yarn pack
51+
- uses: softprops/action-gh-release@v1
52+
with:
53+
draft: true
54+
files: plugins/backstage-plugin-${{ needs.split-tag.outputs.plugin }}/*.tgz

.github/workflows/test.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Test
2+
3+
# This workflow will lint and test a plugin whenever it or CI changes.
4+
5+
on:
6+
push:
7+
branches:
8+
- main
9+
pull_request:
10+
branches:
11+
- main
12+
13+
# Cancel in-progress runs for pull requests when developers push changes.
14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.ref }}
16+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
17+
18+
jobs:
19+
changes:
20+
runs-on: ubuntu-latest
21+
outputs:
22+
plugins: ${{ steps.filter.outputs.changes }}
23+
steps:
24+
# Pull requests do not need to check out the code to detect changes
25+
# because the action fetches changed files through the API.
26+
- uses: actions/checkout@v4
27+
if: github.event_name != 'pull_request'
28+
- uses: dorny/paths-filter@v3
29+
id: filter
30+
with:
31+
filters: |
32+
coder:
33+
- ".github/workflows/build.yaml"
34+
- "plugins/backstage-plugin-coder/**"
35+
plugin:
36+
needs: changes
37+
runs-on: ubuntu-latest
38+
strategy:
39+
matrix:
40+
plugin: ${{ fromJSON(needs.changes.outputs.plugins) }}
41+
name: ${{ matrix.plugin }}
42+
defaults:
43+
run:
44+
working-directory: plugins/backstage-plugin-${{ matrix.plugin }}
45+
steps:
46+
- uses: actions/checkout@v4
47+
- uses: actions/setup-node@v4
48+
with:
49+
node-version-file: .node-version
50+
cache: yarn
51+
- run: yarn install --frozen-lockfile
52+
- run: yarn lint
53+
- run: yarn tsc
54+
- run: yarn test
55+
- run: yarn build
56+
# Version it with the SHA and upload to the run as an artifact in case
57+
# someone needs to download it for testing.
58+
- run: yarn version --new-version "0.0.0-devel+$GITHUB_SHA"
59+
- run: yarn pack
60+
- uses: actions/upload-artifact@v4
61+
with:
62+
name: ${{ matrix.plugin }}
63+
path: plugins/backstage-plugin-${{ matrix.plugin }}/*.tgz

.node-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
18.19.0

.yarnrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# We add the tags ourselves and do not commit the version bump; prevent Yarn
2+
# from trying to do so.
3+
version-git-tag false
4+
version-commit-hooks false

README.md

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,32 @@
11
# [Backstage](https://backstage.io)
22

3-
This is your newly scaffolded Backstage App, Good Luck!
3+
## Contributing
44

5-
To start the app, run:
5+
To start the app:
66

77
```sh
88
yarn install
99
yarn dev
1010
```
11+
12+
To run an individual plugin:
13+
14+
```sh
15+
cd plugins/backstage-plugin-$name
16+
yarn install
17+
yarn start
18+
```
19+
20+
## Releasing
21+
22+
To draft a release for a plugin push a tag named `$name/v$version` without the
23+
`backstage-plugin-` prefix. For example:
24+
25+
```sh
26+
git tag -a coder/v0.0.0 -m "coder v0.0.0"
27+
git push origin coder/v0.0.0
28+
```
29+
30+
This will kick off an action that will create a draft release for the plugin.
31+
Once you have reviewed the release you can publish it and another action will
32+
publish the plugin to NPM.

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@backstage/plugin-techdocs-react": "^1.1.15",
4040
"@backstage/plugin-user-settings": "^0.8.0",
4141
"@backstage/theme": "^0.5.0",
42-
"@coder/backstage-plugin-coder": "^0.1.0",
42+
"@coder/backstage-plugin-coder": "^0.0.0",
4343
"@material-ui/core": "^4.12.2",
4444
"@material-ui/icons": "^4.9.1",
4545
"history": "^5.0.0",

plugins/backstage-plugin-coder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@coder/backstage-plugin-coder",
3-
"version": "0.1.0",
3+
"version": "0.0.0",
44
"main": "src/index.ts",
55
"types": "src/index.ts",
66
"license": "Apache-2.0",

yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9571,7 +9571,7 @@ anymatch@^3.0.3, anymatch@~3.1.2:
95719571
"@backstage/plugin-techdocs-react" "^1.1.15"
95729572
"@backstage/plugin-user-settings" "^0.8.0"
95739573
"@backstage/theme" "^0.5.0"
9574-
"@coder/backstage-plugin-coder" "^0.1.0"
9574+
"@coder/backstage-plugin-coder" "^0.0.0"
95759575
"@material-ui/core" "^4.12.2"
95769576
"@material-ui/icons" "^4.9.1"
95779577
history "^5.0.0"

0 commit comments

Comments
 (0)