Merge pull request #2122 from Bravo555/digital-twin #1319
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: build-workflow | |
on: | |
push: | |
branches: [ main ] | |
tags: | |
- "*" | |
workflow_dispatch: | |
inputs: | |
disable_cache: | |
description: Disable rust caching | |
type: boolean | |
required: false | |
default: false | |
env: | |
CARGO_TERM_COLOR: always | |
RUSTFLAGS: -D warnings | |
jobs: | |
build: | |
name: Build ${{ matrix.job.target }} | |
runs-on: ubuntu-20.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
job: | |
- { target: x86_64-unknown-linux-musl, cache: true } | |
- { target: aarch64-unknown-linux-musl, cache: true } | |
- { target: arm-unknown-linux-musleabihf, cache: true } | |
- { target: armv7-unknown-linux-musleabihf, cache: true } | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Retrieve MSRV from workspace Cargo.toml | |
id: rust_version | |
uses: SebRollen/[email protected] | |
with: | |
file: Cargo.toml | |
field: "workspace.package.rust-version" | |
- name: Enable toolchain via github action | |
uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: ${{ steps.rust_version.outputs.value }} | |
targets: ${{ matrix.job.target }} | |
- name: Enable cache | |
if: ${{ matrix.job.cache && !inputs.disable_cache }} | |
# https://github.com/marketplace/actions/rust-cache | |
uses: Swatinem/rust-cache@v2 | |
# Install nfpm used to for linux packaging | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 'stable' | |
cache: false | |
- run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest | |
- uses: extractions/setup-just@v1 | |
- name: Build for ${{ matrix.job.target }} | |
run: just release ${{ matrix.job.target }} | |
- name: Upload packages as zip | |
# https://github.com/marketplace/actions/upload-a-build-artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: packages-${{ matrix.job.target }} | |
path: target/${{ matrix.job.target }}/packages/*.* | |
publish: | |
name: Publish ${{ matrix.job.target }} | |
runs-on: ubuntu-20.04 | |
needs: [build] | |
strategy: | |
matrix: | |
job: | |
- { target: x86_64-unknown-linux-musl, repo: tedge-main, component: main } | |
- { target: aarch64-unknown-linux-musl, repo: tedge-main, component: main } | |
# Keep arm-unknown-linux-musleabihf in separate repo due to armhf conflict between raspbian and debian | |
- { target: arm-unknown-linux-musleabihf, repo: tedge-main-armv6, component: main } | |
- { target: armv7-unknown-linux-musleabihf, repo: tedge-main, component: main } | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download release artifacts | |
uses: actions/download-artifact@v3 | |
# https://github.com/marketplace/actions/download-a-build-artifact | |
with: | |
name: packages-${{ matrix.job.target }} | |
path: target/${{ matrix.job.target }}/packages/ | |
- uses: extractions/setup-just@v1 | |
- name: Publish packages | |
env: | |
PUBLISH_OWNER: ${{ secrets.PUBLISH_OWNER }} | |
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} | |
run: | | |
just publish-linux-target "${{ matrix.job.target }}" \ | |
--repo "${{ matrix.job.repo }}" \ | |
--component "${{ matrix.job.component }}" | |
# Wait until all other publishing jobs are finished | |
# before publishing the virtual packages (which are architecture agnostic) | |
publish-virtual-packages: | |
name: Publish Virtual Packages | |
runs-on: ubuntu-20.04 | |
needs: [publish] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
# Install nfpm used to for linux packaging | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: 'stable' | |
cache: false | |
- run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest | |
- uses: extractions/setup-just@v1 | |
- name: Build virtual packages | |
run: just release-linux-virtual | |
- name: Publish packages | |
env: | |
PUBLISH_OWNER: ${{ secrets.PUBLISH_OWNER }} | |
PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} | |
run: | | |
just publish-linux-virtual --repo tedge-main | |
just publish-linux-virtual --repo tedge-main-armv6 |