Merge pull request #19 from fermyon/fix-desc #30
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
on: | |
push: | |
branches: | |
- main | |
tags: | |
- "v*" | |
workflow_dispatch: | |
concurrency: ${{ github.workflow }}-${{ github.ref }} | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
name: Build cloud-gpu plugin | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
os: "ubuntu-20.04", | |
arch: "amd64", | |
extension: "", | |
buildArgs: "", | |
target: "", | |
targetDir: "target/release", | |
} | |
- { | |
os: "ubuntu-20.04", | |
arch: "aarch64", | |
extension: "", | |
buildArgs: "--target aarch64-unknown-linux-gnu", | |
target: "aarch64-unknown-linux-gnu", | |
targetDir: "target/aarch64-unknown-linux-gnu/release", | |
} | |
- { | |
os: "macos-latest", | |
arch: "amd64", | |
extension: "", | |
buildArgs: "", | |
target: "", | |
targetDir: "target/release", | |
} | |
- { | |
os: "macos-latest", | |
arch: "aarch64", | |
extension: "", | |
buildArgs: "--target aarch64-apple-darwin", | |
target: "aarch64-apple-darwin", | |
targetDir: "target/aarch64-apple-darwin/release/", | |
} | |
- { | |
os: "windows-latest", | |
arch: "amd64", | |
extension: ".exe", | |
buildArgs: "", | |
target: "", | |
targetDir: "target/release", | |
} | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install latest Rust stable toolchain | |
uses: actions-rs/toolchain@v1 | |
with: | |
toolchain: stable | |
default: true | |
target: ${{ matrix.config.target }} | |
- name: set the release version (main) | |
shell: bash | |
run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV | |
- 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: Install Spin | |
uses: fermyon/actions/spin/setup@v1 | |
with: | |
plugins: js2wasm | |
- name: build fermyon-cloud-gpu | |
shell: bash | |
run: | | |
cd fermyon-cloud-gpu | |
npm install | |
spin build | |
- name: set the release version (main) | |
shell: bash | |
run: echo "RELEASE_VERSION=canary" >> $GITHUB_ENV | |
- 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: lowercase the runner OS name | |
shell: bash | |
run: | | |
OS=$(echo "${{ runner.os }}" | tr '[:upper:]' '[:lower:]') | |
echo "RUNNER_OS=$OS" >> $GITHUB_ENV | |
- name: setup 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 cloud-gpu plugin | |
shell: bash | |
run: | | |
cargo build --release ${{ matrix.config.buildArgs }} | |
- name: Package as plugins tar | |
shell: bash | |
run: | | |
mkdir -v -p _dist/fermyon-cloud-gpu/target | |
cp ${{ matrix.config.targetDir }}/spin-cloud-gpu${{ matrix.config.extension }} _dist/cloud-gpu${{ matrix.config.extension }} | |
cp LICENSE _dist/cloud-gpu.license | |
cp fermyon-cloud-gpu/spin.toml _dist/fermyon-cloud-gpu/spin.toml | |
cp fermyon-cloud-gpu/target/spin-http-js.wasm _dist/fermyon-cloud-gpu/target/spin-http-js.wasm | |
cd _dist | |
tar czf cloud-gpu-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz cloud-gpu.license cloud-gpu${{ matrix.config.extension }} fermyon-cloud-gpu/spin.toml fermyon-cloud-gpu/target/spin-http-js.wasm | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: cloud-gpu | |
path: _dist/cloud-gpu-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz | |
- name: upload binary to Github release | |
if: startsWith(github.ref, 'refs/tags/v') | |
uses: svenstaro/upload-release-action@v2 | |
with: | |
repo_token: ${{ secrets.GITHUB_TOKEN }} | |
file: _dist/cloud-gpu-${{ env.RELEASE_VERSION }}-${{ env.RUNNER_OS }}-${{ matrix.config.arch }}.tar.gz | |
tag: ${{ github.ref }} | |
update-canary: | |
name: update canary release | |
runs-on: ubuntu-latest | |
needs: build | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Download release assets | |
uses: actions/download-artifact@v3 | |
with: | |
name: cloud-gpu | |
- name: Delete canary tag | |
uses: dev-drprasad/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: canary | |
delete_release: true | |
- name: Recreate canary tag and release | |
uses: ncipollo/[email protected] | |
with: | |
tag: canary | |
allowUpdates: true | |
prerelease: true | |
artifacts: "cloud-gpu*.tar.gz" | |
commit: ${{ github.sha }} | |
body: | | |
This is a "canary" release of the most recent commits on our main branch. Canary is **not stable**. | |
It is only intended for developers wishing to try out the latest features in the spin-cloud-gpu plugin | |
## a lot of times we have seen that the canary release is left marked as draft | |
## which is most likely due to some bug in ncipollo/release-action or some unknown misconfiguration on our side | |
## the following command ensure canary release is not marked as draft release | |
- name: Ensure release is not marked as draft | |
run: gh release edit canary --repo fermyon/spin-cloud-gpu --draft=false | |
env: | |
GH_TOKEN: ${{ github.token }} | |
spin-plugin-release: | |
name: Release spin plugin | |
runs-on: ubuntu-latest | |
needs: ['build', 'update-canary'] | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: rajatjindal/spin-plugin-releaser@v1 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
upload_checksums: true | |
template_file: .plugin-manifests/.spin-plugin.json.tmpl |