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