Skip to content

Commit 980eaf8

Browse files
authored
Merge pull request #6 from karthik2804/add_ci
add ci
2 parents b02918e + ca95584 commit 980eaf8

File tree

3 files changed

+188
-1
lines changed

3 files changed

+188
-1
lines changed

.github/workflows/build.yaml

+181
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
name: Build and package
4+
on:
5+
push:
6+
branches: [main]
7+
tags: ["v*"]
8+
pull_request:
9+
branches: [main]
10+
workflow_dispatch:
11+
12+
# TODO: better way?
13+
permissions:
14+
contents: write
15+
16+
env:
17+
PROGRAM_NAME: trigger-command
18+
19+
jobs:
20+
lint:
21+
name: Lint Rust code
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Checkout code
25+
uses: actions/checkout@v2
26+
- name: Install Rust
27+
uses: dtolnay/rust-toolchain@stable
28+
with:
29+
toolchain: 1.74
30+
31+
- name: Install dependencies
32+
run: |
33+
rustup component add rustfmt
34+
rustup component add clippy
35+
36+
- name: lint code
37+
run: make lint
38+
39+
- name: Run Clippy
40+
run: cargo clippy --all -- -D warnings
41+
- name: Cancel everything if linting fails
42+
if: failure()
43+
uses: andymckay/[email protected]
44+
45+
build:
46+
name: Build plugin
47+
runs-on: ${{ matrix.config.os }}
48+
strategy:
49+
fail-fast: false
50+
matrix:
51+
config:
52+
- { target: "x86_64-unknown-linux-gnu", os: "ubuntu-20.04", arch: "amd64", extension: ""}
53+
- { target: "aarch64-unknown-linux-gnu", os: "ubuntu-20.04", arch: "aarch64", extension: "", extraArg: "--features openssl/vendored" }
54+
- { target: "x86_64-apple-darwin", os: "macos-latest", arch: "amd64", extension: "" }
55+
- { target: "aarch64-apple-darwin", os: "macos-latest", arch: "aarch64", extension: "" }
56+
- { target: "x86_64-pc-windows-msvc", os: "windows-latest", arch: "amd64", extension: ".exe" }
57+
steps:
58+
- uses: actions/checkout@v3
59+
- uses: Swatinem/rust-cache@v2
60+
with:
61+
shared-key: "${{ runner.os }}-lint-${{ hashFiles('./Cargo.lock') }}"
62+
cache-on-failure: "true"
63+
- name: Install Rust
64+
uses: dtolnay/rust-toolchain@stable
65+
with:
66+
toolchain: 1.74
67+
targets: ${{ matrix.config.target }}
68+
- name: Install Spin
69+
uses: rajatjindal/setup-actions/spin@main
70+
with:
71+
version: "v0.8.0"
72+
- name: Install pluginify
73+
shell: bash
74+
run: spin plugins install --url https://github.com/itowlson/spin-pluginify/releases/download/canary/pluginify.json --yes
75+
- name: Set up for cross-compiled linux aarch64 build
76+
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
77+
run: |
78+
sudo apt update
79+
sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
80+
echo '[target.aarch64-unknown-linux-gnu]' >> ${HOME}/.cargo/config.toml
81+
echo 'linker = "aarch64-linux-gnu-gcc"' >> ${HOME}/.cargo/config.toml
82+
- name: Build plugin binary
83+
run: cargo build --release --target ${{ matrix.config.target }} ${{ matrix.config.extraArg }}
84+
- name: Copy plugin binary to standard location
85+
shell: bash
86+
run: cp target/${{ matrix.config.target }}/release/${{ env.PROGRAM_NAME}}${{ matrix.config.extension }} target/release/${{ env.PROGRAM_NAME}}${{ matrix.config.extension }}
87+
88+
- name: Pluginify plugin binary
89+
run: spin pluginify --arch ${{ matrix.config.arch }}
90+
- name: Archive pluginified
91+
uses: actions/upload-artifact@v3
92+
with:
93+
name: ${{ env.PROGRAM_NAME}}-${{ matrix.config.os }}-${{ matrix.config.arch }}
94+
path: |
95+
*.tar.gz
96+
*.json
97+
98+
package:
99+
name: Package plugin
100+
if: github.event_name == 'push'
101+
runs-on: ubuntu-latest
102+
needs: build
103+
steps:
104+
- name: Install Spin
105+
uses: rajatjindal/setup-actions/spin@main
106+
with:
107+
version: "v2.0.0"
108+
- name: Install pluginify
109+
shell: bash
110+
run: spin plugins install --url https://github.com/itowlson/spin-pluginify/releases/download/canary/pluginify.json --yes
111+
112+
- name: set the release version (tag)
113+
if: startsWith(github.ref, 'refs/tags/v')
114+
shell: bash
115+
run: echo "RELEASE_VERSION=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
116+
- name: set the release version (main)
117+
if: github.ref == 'refs/heads/main'
118+
shell: bash
119+
run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV
120+
- name: set the release version (TEST TEST TEST)
121+
if: github.event_name == 'pull_request'
122+
shell: bash
123+
run: echo "RELEASE_VERSION=precanary" >> $GITHUB_ENV
124+
125+
- name: Download artifacts
126+
uses: actions/download-artifact@v3
127+
- name: Display structure of downloaded files
128+
run: ls -R
129+
- name: pluginify it
130+
run: |
131+
spin pluginify --merge --release-url-base https://github.com/fermyon/spin-trigger-command/releases/download/${{ env.RELEASE_VERSION }}/ >${{ env.PROGRAM_NAME }}.json
132+
- name: Display merged manifest
133+
run: cat ${{ env.PROGRAM_NAME }}.json
134+
135+
# Handle versioned release
136+
- name: Upload tars to Github release
137+
if: startsWith(github.ref, 'refs/tags/v')
138+
uses: svenstaro/upload-release-action@v2
139+
with:
140+
repo_token: ${{ secrets.GITHUB_TOKEN }}
141+
file: "**/*.tar.gz"
142+
file_glob: true
143+
tag: ${{ github.ref }}
144+
- name: Upload manifest to Github release
145+
if: startsWith(github.ref, 'refs/tags/v')
146+
uses: svenstaro/upload-release-action@v2
147+
with:
148+
repo_token: ${{ secrets.GITHUB_TOKEN }}
149+
file: ${{ env.PROGRAM_NAME }}.json
150+
tag: ${{ github.ref }}
151+
152+
# Handle canary release
153+
- name: Delete canary tag
154+
if: github.ref == 'refs/heads/main'
155+
uses: dev-drprasad/[email protected]
156+
env:
157+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
158+
with:
159+
tag_name: canary
160+
- name: Recreate canary tag and release
161+
if: github.ref == 'refs/heads/main'
162+
uses: ncipollo/[email protected]
163+
with:
164+
tag: canary
165+
allowUpdates: true
166+
prerelease: true
167+
- name: Upload tars to Github release
168+
if: github.ref == 'refs/heads/main'
169+
uses: svenstaro/upload-release-action@v2
170+
with:
171+
repo_token: ${{ secrets.GITHUB_TOKEN }}
172+
file: "**/*.tar.gz"
173+
file_glob: true
174+
tag: canary
175+
- name: Upload manifest to Github release
176+
if: github.ref == 'refs/heads/main'
177+
uses: svenstaro/upload-release-action@v2
178+
with:
179+
repo_token: ${{ secrets.GITHUB_TOKEN }}
180+
file: ${{ env.PROGRAM_NAME }}.json
181+
tag: canary

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,17 @@ async-trait = "0.1"
1818
clap = { version = "3.1.15", features = ["derive", "env"] }
1919
serde = "1.0"
2020
spin-app = { git = "https://github.com/fermyon/spin", tag = "v2.4.0" }
21-
spin-core = { git = "https://github.com/fermyon/spin", tag = "v2.4.0" }
21+
spin-core = { git = "https://github.com/fermyon/spin", tag = "v2.4.0" }
2222
spin-trigger = { git = "https://github.com/fermyon/spin", tag = "v2.4.0" }
2323
tokio = { version = "1.23", features = ["full"] }
2424
tracing = { version = "0.1", features = ["log"] }
2525
tracing-subscriber = { version = "0.3.7", features = ["env-filter"] }
2626
wasmtime-wasi = { version = "18.0.1", features = ["tokio"] }
2727

28+
[target.'cfg(target_os = "linux")'.dependencies]
29+
# This needs to be an explicit dependency to enable
30+
# '--features openssl/vendored', which is used for Linux releases.
31+
openssl = { version = "0.10" }
32+
2833
[workspace.dependencies]
2934
wit-bindgen = "0.16.0"

0 commit comments

Comments
 (0)