Skip to content

Commit 7666def

Browse files
authored
Merge pull request #4 from asteurer/main
initial commit
2 parents 0d2ddaa + 5a6f21b commit 7666def

File tree

16 files changed

+1230
-0
lines changed

16 files changed

+1230
-0
lines changed

.github/workflows/main.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches: [main]
6+
tags: ["v*"]
7+
pull_request:
8+
branches: [main]
9+
workflow_dispatch:
10+
11+
env:
12+
PROGRAM_NAME: blueprint
13+
SPIN_VERSION: v2.7.0
14+
jobs:
15+
test-and-build:
16+
name: Run the tests, and build plugin binaries
17+
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
config:
21+
# The architectures and operating systems accepted by Golang and the Pluginify tool are different for macos + arm64
22+
- { goArch: "amd64", goOs: "linux", pluginifyArch: "amd64", pluginifyOs: linux}
23+
- { goArch: "arm64", goOs: "linux", pluginifyArch: "aarch64", pluginifyOs: linux}
24+
- { goArch: "arm64", goOs: "darwin", pluginifyArch: "amd64", pluginifyOs: macos}
25+
- { goArch: "amd64", goOs: "darwin", pluginifyArch: "aarch64", pluginifyOs: macos}
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
30+
- name: Setup Go
31+
uses: actions/setup-go@v5
32+
with:
33+
go-version: stable
34+
35+
- name: Run tests
36+
run: make test
37+
38+
- name: Install Spin
39+
uses: rajatjindal/setup-actions/spin@main
40+
with:
41+
version: ${{ env.SPIN_VERSION }}
42+
43+
- name: Install Pluginify
44+
run: spin plugins install --url https://github.com/itowlson/spin-pluginify/releases/download/canary/pluginify.json --yes
45+
46+
- name: Build Plugin Binary
47+
run: GOOS=${{ matrix.config.goOs }} GOARCH=${{ matrix.config.goArch }} go build -o ${{ env.PROGRAM_NAME }} main.go
48+
49+
- name: Create Arch-Specific Plugin Manifest
50+
run: spin pluginify --arch ${{ matrix.config.pluginifyArch }} --os ${{ matrix.config.pluginifyOs }}
51+
52+
- name: Archive Binary and Manifest
53+
uses: actions/upload-artifact@v4
54+
with:
55+
name: ${{ env.PROGRAM_NAME}}-${{ matrix.config.pluginifyOs }}-${{ matrix.config.pluginifyArch }}
56+
path: |
57+
*.tar.gz
58+
*.json
59+
60+
package:
61+
name: Package Plugin
62+
runs-on: ubuntu-latest
63+
permissions:
64+
contents: write
65+
needs: test-and-build
66+
if: github.event_name == 'push'
67+
steps:
68+
- name: Install Spin
69+
uses: rajatjindal/setup-actions/spin@main
70+
with:
71+
version: ${{ env.SPIN_VERSION }}
72+
- name: Install Pluginify
73+
run: spin plugins install --url https://github.com/itowlson/spin-pluginify/releases/download/canary/pluginify.json --yes
74+
75+
- name: set the release version (tag)
76+
if: startsWith(github.ref, 'refs/tags/v')
77+
run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
78+
- name: set the release version (main)
79+
if: github.ref == 'refs/heads/main'
80+
run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV
81+
82+
- name: Download artifacts
83+
uses: actions/download-artifact@v4
84+
- name: Display structure of downloaded files
85+
run: ls -R
86+
- name: pluginify it
87+
run: |
88+
spin pluginify --merge --release-url-base https://github.com/fermyon/blueprint-plugin/releases/download/${{ env.RELEASE_VERSION }}/ >${{ env.PROGRAM_NAME }}.json
89+
- name: Display merged manifest
90+
run: cat ${{ env.PROGRAM_NAME }}.json
91+
- name: Archive Combined Manifest
92+
uses: actions/upload-artifact@v4
93+
with:
94+
path: ${{ env.PROGRAM_NAME }}.json
95+
96+
- name: Gather all new release files
97+
run: |
98+
mkdir release-assets
99+
find . -name "*.tar.gz" -exec cp {} release-assets/ \;
100+
cp ${{ env.PROGRAM_NAME }}.json release-assets/
101+
ls release-assets/
102+
103+
# Handle versioned release
104+
- name: Create versioned release
105+
if: startsWith(github.ref, 'refs/tags/v')
106+
run: gh release create ${{ env.RELEASE_VERSION }} --title "${{ env.RELEASE_VERSION }}" --repo ${{ github.repository }} release-assets/*
107+
env:
108+
GH_TOKEN: ${{ github.token }}
109+
110+
# Handle canary release
111+
- name: Delete canary release
112+
if: github.ref == 'refs/heads/main'
113+
run: gh release delete ${{ env.RELEASE_VERSION }} --repo ${{ github.repository }} --cleanup-tag || echo "Release not found, continuing..."
114+
env:
115+
GH_TOKEN: ${{ github.token }}
116+
- name: Recreate canary release
117+
if: github.ref == 'refs/heads/main'
118+
run: gh release create ${{ env.RELEASE_VERSION }} --title "${{ env.RELEASE_VERSION }}" --prerelease --repo ${{ github.repository }} release-assets/*
119+
env:
120+
GH_TOKEN: ${{ github.token }}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
blueprint
2+
*.json
3+
*.tar.gz

LICENSE

Whitespace-only changes.

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.PHONY: test
2+
3+
test:
4+
go test ./... -v

README.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Spin Blueprint Plugin
2+
3+
This is a plugin that helps to visualize the different components within a Spin application.
4+
5+
# Installation
6+
7+
## Install the latest version of the plugin
8+
9+
The latest stable release of the blueprint plugin can be installed like so:
10+
11+
```sh
12+
spin plugins update
13+
spin plugin install blueprint
14+
```
15+
16+
## Install the canary version of the plugin
17+
18+
The canary release of the command trigger plugin represents the most recent commits on `main` and may not be stable, with some features still in progress.
19+
20+
```sh
21+
spin plugins install --url https://github.com/fermyon/blueprint-plugin/releases/download/canary/blueprint.json
22+
```
23+
24+
## Install from a local build
25+
26+
Alternatively, use the `spin pluginify` plugin to install from a fresh build. This will use the pluginify manifest (`spin-pluginify.toml`) to package the plugin and proceed to install it:
27+
28+
```sh
29+
spin plugins install pluginify
30+
go build -o blueprint main.go
31+
spin pluginify --install
32+
```
33+
34+
# Usage
35+
36+
This plugin will read a `spin.toml` file within the same directory--or whatever path specified in the `--file` flag--and output tables detailing the Spin application as a whole, as well as individual components.
37+
38+
## See all available commands and flags:
39+
40+
```sh
41+
spin blueprint --help
42+
```
43+
44+
## Show all components
45+
46+
If in your terminal you are in the same directory as a spin.toml file:
47+
48+
```sh
49+
spin blueprint show
50+
```
51+
52+
If your spin.toml file is somewhere else:
53+
54+
```sh
55+
56+
spin blueprint show --file path/to/spin.toml
57+
```
58+
59+
## Show a specific component
60+
61+
If in your terminal you are in the same directory as a spin.toml file:
62+
63+
```sh
64+
spin blueprint show component-name
65+
```
66+
67+
If your spin.toml file is somewhere else:
68+
69+
```sh
70+
spin blueprint show --file path/to/spin.toml component-name
71+
```
72+
73+
## Loading environment variables
74+
75+
You can pass environment variables directly:
76+
77+
```sh
78+
SPIN_VARIABLE_FOO=bar spin blueprint show --file path/to/spin.toml
79+
```
80+
81+
Or read a `.env` file:
82+
83+
```sh
84+
spin blueprint --env path/to/file.env show component-name
85+
```

cmd/root.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package cmd
2+
3+
import (
4+
"os"
5+
6+
"github.com/spf13/cobra"
7+
)
8+
9+
// rootCmd represents the base command when called without any subcommands
10+
var rootCmd = &cobra.Command{
11+
Use: "blueprint",
12+
Short: "This is a plugin that helps to visualize the different components within a Spin application",
13+
}
14+
15+
func Execute() {
16+
err := rootCmd.Execute()
17+
if err != nil {
18+
os.Exit(1)
19+
}
20+
}
21+
22+
func init() {
23+
showCmd.PersistentFlags().StringP("file", "f", "", "Specifies the path to the spin.toml file you wish to visualize")
24+
showCmd.PersistentFlags().StringP("env", "e", "", "Specifies the path to the \".env\" file containing your Spin variables")
25+
rootCmd.AddCommand(showCmd)
26+
}

0 commit comments

Comments
 (0)