-
Notifications
You must be signed in to change notification settings - Fork 8
155 lines (145 loc) · 5.71 KB
/
build.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
name: Build and package
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]
# TODO: better way?
permissions:
contents: write
env:
PROGRAM_NAME: trigger-cron
jobs:
build:
name: Build plugin
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- { target: "x86_64-unknown-linux-gnu", os: "ubuntu-20.04", arch: "amd64", extension: ""}
- { target: "aarch64-unknown-linux-gnu", os: "ubuntu-20.04", arch: "aarch64", extension: "", extraArg: "--features openssl/vendored" }
- { target: "x86_64-apple-darwin", os: "macos-latest", arch: "amd64", extension: "" }
- { target: "aarch64-apple-darwin", os: "macos-latest", arch: "aarch64", extension: "" }
- { target: "x86_64-pc-windows-msvc", os: "windows-latest", arch: "amd64", extension: ".exe" }
steps:
- uses: actions/checkout@v3
- uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-lint-${{ hashFiles('./Cargo.lock') }}"
cache-on-failure: "true"
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.74
targets: ${{ matrix.config.target }}
- name: Install Spin
uses: rajatjindal/setup-actions/spin@main
with:
version: "v0.8.0"
- name: Install pluginify
shell: bash
run: spin plugins install --url https://github.com/itowlson/spin-pluginify/releases/download/canary/pluginify.json --yes
- name: Set up for cross-compiled linux aarch64 build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt update
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
echo '[target.aarch64-unknown-linux-gnu]' >> ${HOME}/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml
- name: Build plugin binary
run: cargo build --release --target ${{ matrix.config.target }} ${{ matrix.config.extraArg }}
- name: Copy plugin binary to standard location
shell: bash
run: cp target/${{ matrix.config.target }}/release/${{ env.PROGRAM_NAME}}${{ matrix.config.extension }} target/release/${{ env.PROGRAM_NAME}}${{ matrix.config.extension }}
- name: Pluginify plugin binary
run: spin pluginify --arch ${{ matrix.config.arch }}
- name: Archive pluginified
uses: actions/upload-artifact@v3
with:
name: ${{ env.PROGRAM_NAME}}-${{ matrix.config.os }}-${{ matrix.config.arch }}
path: |
*.tar.gz
*.json
package:
name: Package plugin
if: github.event_name == 'push'
runs-on: ubuntu-latest
needs: build
steps:
- name: Install Spin
uses: rajatjindal/setup-actions/spin@main
with:
version: "v2.0.0"
- name: Install pluginify
shell: bash
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')
shell: bash
run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
- name: set the release version (main)
if: github.ref == 'refs/heads/main'
shell: bash
run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV
- name: set the release version (TEST TEST TEST)
if: github.event_name == 'pull_request'
shell: bash
run: echo "RELEASE_VERSION=precanary" >> $GITHUB_ENV
- name: Download artifacts
uses: actions/download-artifact@v3
- name: Display structure of downloaded files
run: ls -R
- name: pluginify it
run: |
spin pluginify --merge --release-url-base https://github.com/fermyon/spin-trigger-cron/releases/download/${{ env.RELEASE_VERSION }}/ >${{ env.PROGRAM_NAME }}.json
- name: Display merged manifest
run: cat ${{ env.PROGRAM_NAME }}.json
# Handle versioned release
- name: Upload tars to Github release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "**/*.tar.gz"
file_glob: true
tag: ${{ github.ref }}
- name: Upload manifest to Github release
if: startsWith(github.ref, 'refs/tags/v')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.PROGRAM_NAME }}.json
tag: ${{ github.ref }}
# Handle canary release
- name: Delete canary tag
if: github.ref == 'refs/heads/main'
uses: dev-drprasad/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: canary
- name: Recreate canary tag and release
if: github.ref == 'refs/heads/main'
uses: ncipollo/[email protected]
with:
tag: canary
allowUpdates: true
prerelease: true
- name: Upload tars to Github release
if: github.ref == 'refs/heads/main'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: "**/*.tar.gz"
file_glob: true
tag: canary
- name: Upload manifest to Github release
if: github.ref == 'refs/heads/main'
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.PROGRAM_NAME }}.json
tag: canary