This repository has been archived by the owner on Dec 25, 2024. It is now read-only.
Added extension methods to get workspace id and live mode from options #314
Workflow file for this run
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 | |
on: | |
push: | |
# branches: | |
# - main | |
tags: | |
- '*' | |
paths-ignore: | |
- README.md | |
- LICENSE | |
- CHANGELOG.md | |
- docs/** | |
pull_request: | |
branches: | |
- main | |
paths-ignore: | |
- README.md | |
- LICENSE | |
- CHANGELOG.md | |
- docs/** | |
workflow_dispatch: | |
env: | |
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1 | |
PKG_NAME: 'falu' | |
PKG_DESCRIPTION: 'Falu CLI' | |
PKG_MAINTAINER: 'Falu <[email protected]>' | |
PKG_HOMEPAGE: 'https://falu.io' | |
PKG_VENDOR: FALU TECHNOLOGIES LIMITED | |
PKG_LICENSE: MIT | |
DOCKER_IMAGE_NAME: ghcr.io/${{ github.repository_owner }}/falu-cli | |
jobs: | |
Build: | |
strategy: | |
fail-fast: true | |
matrix: | |
os: [ 'macos', 'ubuntu', 'windows'] | |
arch: [ 'x64', 'arm64' ] | |
include: | |
- { os: ubuntu, arch: x64, deb-arch: amd64, rpm-arch: x86_64 } | |
- { os: ubuntu, arch: arm64, deb-arch: arm64, rpm-arch: aarch64 } | |
- { os: ubuntu, arch: x64, docker-platform: 'linux/amd64', docker-tag-suffix: '-amd64' } | |
- { os: ubuntu, arch: arm64, docker-platform: 'linux/arm64/v8', docker-tag-suffix: '-arm64' } | |
# list of RIDs (Runtime Identifiers) can be found at: | |
# https://github.com/dotnet/runtime/blob/main/src/libraries/Microsoft.NETCore.Platforms/src/runtime.json | |
- { os: ubuntu, rid-prefix: 'linux' } | |
- { os: windows, rid-prefix: 'win' } | |
- { os: macos, rid-prefix: 'osx' } | |
# macos-latest uses macos-12 which fails to build the app (macos-13 works) | |
- { os: macos, runs-on: 'macos-13' } # macos-latest | |
- { os: windows, archive-type: 'zip' } # windows creates zip files, others default to 'tar' | |
runs-on: ${{ matrix.runs-on || format('{0}-{1}', matrix.os, 'latest') }} | |
env: | |
DOTNET_RID: ${{ format('{0}-{1}', matrix.rid-prefix, matrix.arch) }} | |
outputs: | |
BINARIES_VERSION: ${{ steps.gitversion.outputs.nuGetVersionV2 }} | |
DOCKER_IMAGE_LABELS: ${{ steps.docker-meta.outputs.labels }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Required for GitVersion | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v1 | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
uses: gittools/actions/gitversion/execute@v1 | |
id: gitversion | |
with: | |
useConfigFile: true | |
- name: Setup .NET SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '8.x' | |
- name: Install dependencies | |
run: dotnet restore --runtime ${{ env.DOTNET_RID }} -v detailed | |
- name: Build | |
if: github.event_name == 'pull_request' | |
run: dotnet build --configuration Release --no-restore | |
- name: Test | |
if: github.event_name == 'pull_request' | |
run: dotnet test --configuration Release --no-build --collect "Code coverage" | |
- name: Publish | |
run: > | |
dotnet publish | |
-p:PublishSingleFile=true | |
-p:DebugType=None | |
-p:DebugSymbols=false | |
-p:PublishTrimmed=true | |
-p:AssemblyName=falu | |
-p:PackageVersion=${{ steps.gitversion.outputs.nuGetVersionV2 }} | |
-p:VersionPrefix=${{ steps.gitversion.outputs.nuGetVersionV2 }} | |
--runtime ${{ env.DOTNET_RID }} | |
--configuration Release | |
--output ${{ github.workspace }}/drop/${{ env.DOTNET_RID }} | |
--self-contained true | |
--no-restore | |
src/FaluCli/FaluCli.csproj | |
- name: Test (Binary) # ensure the CLI can launch (catches global DI issues) | |
# ARM runners are in preview and we cannot use them, so we skip this test | |
# https://github.blog/changelog/2023-10-30-accelerate-your-ci-cd-with-arm-based-hosted-runners-in-github-actions/ | |
# TODO: consider using QEMU emulator for ARM? | |
if: ${{ !contains(matrix.arch, 'arm') }} | |
run: ./falu logout | |
working-directory: ${{ github.workspace }}/drop/${{ env.DOTNET_RID }} | |
- name: Upload Artifact (drop) | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/drop/** | |
name: drop-${{ env.DOTNET_RID }} | |
retention-days: 1 | |
- name: Create Archive Folder | |
run: mkdir ${{ github.workspace }}/releases | |
- name: Create Archive (${{ matrix.archive-type || 'tar.gz' }}) | |
uses: thedoctor0/zip-release@master | |
with: | |
type: ${{ matrix.archive-type || 'tar' }} | |
filename: ${{ github.workspace }}/releases/falu-${{ steps.gitversion.outputs.nuGetVersionV2 }}-${{ env.DOTNET_RID }}.${{ matrix.archive-type || 'tar.gz' }} | |
directory: ${{ github.workspace }}/drop/${{ env.DOTNET_RID }} | |
- name: Prepare .debpkg and .rpmpkg | |
if: ${{ matrix.deb-arch || matrix.rpm-arch }} | |
run: | | |
mkdir -p .debpkg/usr/bin | |
cp -p ${{ github.workspace }}/drop/${{ env.DOTNET_RID }}/* .debpkg/usr/bin/ | |
mkdir -p .rpmpkg/usr/bin | |
cp -p ${{ github.workspace }}/drop/${{ env.DOTNET_RID }}/* .rpmpkg/usr/bin/ | |
- name: 'Build DEB package' | |
uses: jiro4989/build-deb-action@v3 | |
if: ${{ matrix.deb-arch }} | |
with: | |
desc: '${{ env.PKG_DESCRIPTION }}' | |
maintainer: ${{ env.PKG_MAINTAINER }} | |
version: ${{ steps.gitversion.outputs.nuGetVersionV2 }} | |
package: ${{ env.PKG_NAME }} | |
package_root: .debpkg | |
arch: '${{ matrix.deb-arch}}' | |
- name: 'Build RPM package' | |
uses: jiro4989/build-rpm-action@v2 | |
# TODO: build RPM package for ARM once we have ARM runners | |
# https://github.blog/changelog/2023-10-30-accelerate-your-ci-cd-with-arm-based-hosted-runners-in-github-actions/ | |
# Not possible on x64 runners: https://github.com/jiro4989/build-rpm-action/issues/6 | |
# if: ${{ matrix.rpm-arch }} | |
if: ${{ matrix.rpm-arch && matrix.arch == 'x64' }} | |
with: | |
summary: '${{ env.PKG_DESCRIPTION }}' | |
desc: '${{ env.PKG_DESCRIPTION }}' | |
maintainer: ${{ env.PKG_MAINTAINER }} | |
vendor: ${{ env.PKG_VENDOR }} | |
license: ${{ env.PKG_LICENSE }} | |
version: ${{ steps.gitversion.outputs.majorMinorPatch }} | |
package: ${{ env.PKG_NAME }} | |
package_root: .rpmpkg | |
arch: '${{ matrix.rpm-arch}}' | |
- name: Rename deb and rpm packages | |
if: ${{ matrix.deb-arch || matrix.rpm-arch }} | |
run: | | |
src=falu_${{ steps.gitversion.outputs.nuGetVersionV2 }}_${{ matrix.deb-arch}}.deb | |
dest=${{ github.workspace }}/releases/falu-${{ steps.gitversion.outputs.nuGetVersionV2 }}-linux-${{ matrix.deb-arch}}.deb | |
mv $src $dest | |
src=falu-${{ steps.gitversion.outputs.majorMinorPatch }}-1.el7.${{ matrix.rpm-arch}}.rpm | |
dest=${{ github.workspace }}/releases/falu-${{ steps.gitversion.outputs.nuGetVersionV2 }}-linux-${{ matrix.rpm-arch}}.rpm | |
if [ -f $src ]; then | |
mv $src $dest | |
fi | |
- name: Upload Artifact (releases) | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/releases/** | |
name: releases-${{ env.DOTNET_RID }} | |
retention-days: 1 | |
- name: Test (DEB) | |
# TODO: test DEB package for ARM once we have ARM runners | |
# https://github.blog/changelog/2023-10-30-accelerate-your-ci-cd-with-arm-based-hosted-runners-in-github-actions/ | |
# if: ${{ matrix.deb-arch }} | |
if: ${{ matrix.deb-arch && matrix.arch == 'x64' }} | |
run: | | |
sudo apt-get install -y -f \ | |
${{ github.workspace }}/releases/falu-${{ steps.gitversion.outputs.nuGetVersionV2 }}-linux-${{ matrix.deb-arch}}.deb | |
- name: Test (RPM) | |
# TODO: test RPM package for ARM once we have ARM runners | |
# https://github.blog/changelog/2023-10-30-accelerate-your-ci-cd-with-arm-based-hosted-runners-in-github-actions/ | |
# if: ${{ matrix.rpm-arch }} | |
if: ${{ matrix.rpm-arch && matrix.arch == 'x64' }} | |
run: | | |
sudo apt-get install alien | |
sudo alien -i \ | |
${{ github.workspace }}/releases/falu-${{ steps.gitversion.outputs.nuGetVersionV2 }}-linux-${{ matrix.rpm-arch}}.rpm | |
- name: Set up Docker QEMU | |
if: ${{ matrix.docker-platform && matrix.arch == 'arm64' }} | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
if: ${{ matrix.docker-platform }} | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker container registry | |
if: ${{ matrix.docker-platform && github.actor != 'dependabot[bot]' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract docker metadata (tags, labels) | |
if: ${{ matrix.docker-platform }} | |
id: docker-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_IMAGE_NAME }} | |
labels: | | |
com.github.image.run.id=${{ github.run_id }} | |
com.github.image.run.number=${{ github.run_number }} | |
com.github.image.job.id=${{ github.job }} | |
com.github.image.source.sha=${{ github.sha }} | |
com.github.image.source.branch=${{ github.ref }} | |
org.opencontainers.image.title="Falu CLI" | |
org.opencontainers.image.documentation="https://falu.io/docs/cli" | |
org.opencontainers.image.authors="Falu <[email protected]>" | |
org.opencontainers.image.vendor="Falu" | |
org.opencontainers.image.version=${{ steps.gitversion.outputs.nuGetVersionV2 }} | |
org.opencontainers.image.revision=${{ github.sha }} | |
tags: | | |
${{ steps.gitversion.outputs.nuGetVersionV2 }}${{ matrix.docker-tag-suffix }} | |
${{ env.LATEST_TAG }} | |
env: | |
LATEST_TAG: ${{ (startsWith(github.ref, 'refs/tags') && format('latest{0}', matrix.docker-tag-suffix)) || '' }} | |
- name: Build docker image | |
if: ${{ matrix.docker-platform }} | |
id: docker-build | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: ${{ matrix.docker-platform }} | |
file: ${{ github.workspace }}/Dockerfile | |
context: ${{ github.workspace }}/drop/${{ env.DOTNET_RID }} | |
labels: ${{ steps.docker-meta.outputs.labels }} | |
tags: ${{ steps.docker-meta.outputs.tags }} | |
load: true | |
# provenance=false prevents untagged images from being pushed | |
# https://github.com/docker/build-push-action/issues/894#issuecomment-1785937908 | |
provenance: false | |
- name: Test (Docker) | |
if: ${{ matrix.docker-platform }} | |
run: docker run --rm ${{ env.DOCKER_IMAGE_NAME }}:${{ steps.gitversion.outputs.nuGetVersionV2 }}${{ matrix.docker-tag-suffix }} --version | |
- name: Push docker image | |
if: ${{ matrix.docker-platform && github.actor != 'dependabot[bot]' }} | |
uses: docker/build-push-action@v5 | |
with: | |
platforms: ${{ matrix.docker-platform }} | |
file: ${{ github.workspace }}/Dockerfile | |
context: ${{ github.workspace }}/drop/${{ env.DOTNET_RID }} | |
labels: ${{ steps.docker-meta.outputs.labels }} | |
tags: ${{ steps.docker-meta.outputs.tags }} | |
push: true | |
# provenance=false prevents untagged images from being pushed | |
# https://github.com/docker/build-push-action/issues/894#issuecomment-1785937908 | |
provenance: false | |
- name: Export docker digest | |
if: ${{ matrix.docker-platform }} | |
run: | | |
mkdir -p ${{ github.workspace }}/docker-digests | |
digest="${{ steps.docker-build.outputs.digest }}" | |
touch "${{ github.workspace }}/docker-digests/${digest#sha256:}" | |
- name: Upload artifact (digest) | |
if: ${{ matrix.docker-platform }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docker-digests-${{ env.DOTNET_RID }} | |
path: ${{ github.workspace }}/docker-digests/* | |
retention-days: 1 | |
if-no-files-found: error | |
DockerMerge: | |
name: Docker Merge Manifests | |
runs-on: ubuntu-latest | |
needs: [ Build ] | |
steps: | |
- name: Download Artifact (docker-digests) | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/docker-digests | |
pattern: docker-digests-* | |
merge-multiple: true | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker container registry | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract docker metadata (tags, labels) | |
id: docker-meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_IMAGE_NAME }} | |
labels: ${{ needs.Build.outputs.DOCKER_IMAGE_LABELS }} | |
tags: | | |
${{ needs.Build.outputs.BINARIES_VERSION }} | |
${{ env.LATEST_TAG }} | |
env: | |
LATEST_TAG: ${{ (startsWith(github.ref, 'refs/tags') && 'latest') || '' }} | |
- name: Create manifest list and push | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
working-directory: ${{ github.workspace }}/docker-digests | |
run: | | |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | |
$(printf '${{ env.DOCKER_IMAGE_NAME }}@sha256:%s ' *) | |
- name: Inspect image | |
if: ${{ github.actor != 'dependabot[bot]' }} | |
run: | | |
docker buildx imagetools inspect ${{ env.DOCKER_IMAGE_NAME }}:${{ needs.Build.outputs.BINARIES_VERSION }} | |
Checksum: | |
runs-on: ubuntu-latest | |
needs: [ Build ] | |
steps: | |
- name: Download Artifact (releases) | |
uses: actions/download-artifact@v4 | |
with: | |
path: releases | |
pattern: releases-* | |
merge-multiple: true | |
- name: Generate checksum | |
uses: jmgilman/actions-generate-checksum@v1 | |
with: | |
method: 'sha256' | |
output: 'checksum.txt' | |
patterns: | | |
releases/falu-*.deb | |
releases/falu-*.rpm | |
releases/falu-*.tar.gz | |
releases/falu-*.zip | |
# retain only the file names | |
# waiting on https://github.com/jmgilman/actions-generate-checksum/pull/2 | |
- name: Strip directory | |
uses: jacobtomlinson/gha-find-replace@v3 | |
with: | |
find: "releases/falu-" | |
replace: "falu-" | |
include: checksum.txt | |
- name: Upload Artifact (releases) | |
uses: actions/upload-artifact@v4 | |
with: | |
path: checksum.txt | |
name: releases-checksum | |
retention-days: 1 | |
Packaging: | |
runs-on: macos-latest | |
needs: [ Build ] | |
outputs: | |
BINARIES_VERSION: ${{ needs.Build.outputs.BINARIES_VERSION }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Download Artifact (releases) | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/releases | |
pattern: releases-* | |
merge-multiple: true | |
- name: Prepare templates | |
run: | | |
mkdir -p ${{ github.workspace }}/generated/homebrew/ | |
mv packaging/homebrew/formula-template.rb ${{ github.workspace }}/generated/homebrew/falu.rb | |
mkdir -p ${{ github.workspace }}/generated/scoop/ | |
mv packaging/scoop/bucket-template.json ${{ github.workspace }}/generated/scoop/falu.json | |
- name: Prepare variables | |
working-directory: ${{ github.workspace }}/releases | |
run: | | |
echo "BINARIES_VERSION=$BINARIES_VERSION" >> "$GITHUB_ENV" | |
checksumMacARM64=$(shasum -a 256 falu-$BINARIES_VERSION-osx-arm64.tar.gz | cut -d " " -f 1) | |
checksumMacX64=$(shasum -a 256 falu-$BINARIES_VERSION-osx-x64.tar.gz | cut -d " " -f 1) | |
checksumLinuxARM64=$(shasum -a 256 falu-$BINARIES_VERSION-linux-arm64.tar.gz | cut -d " " -f 1) | |
checksumLinuxX64=$(shasum -a 256 falu-$BINARIES_VERSION-linux-x64.tar.gz | cut -d " " -f 1) | |
checksumWindowsARM64=$(shasum -a 256 falu-$BINARIES_VERSION-win-arm64.zip | cut -d " " -f 1) | |
checksumWindowsX64=$(shasum -a 256 falu-$BINARIES_VERSION-win-x64.zip | cut -d " " -f 1) | |
echo "MACOS_ARM64_BINARY_SHA256=$checksumMacARM64" >> "$GITHUB_ENV" | |
echo "MACOS_X64_BINARY_SHA256=$checksumMacX64" >> "$GITHUB_ENV" | |
echo "LINUX_ARM64_BINARY_SHA256=$checksumLinuxARM64" >> "$GITHUB_ENV" | |
echo "LINUX_X64_BINARY_SHA256=$checksumLinuxX64" >> "$GITHUB_ENV" | |
echo "WINDOWS_ARM64_BINARY_SHA256=$checksumWindowsARM64" >> "$GITHUB_ENV" | |
echo "WINDOWS_X64_BINARY_SHA256=$checksumWindowsX64" >> "$GITHUB_ENV" | |
env: | |
BINARIES_VERSION: ${{ needs.Build.outputs.BINARIES_VERSION }} | |
- name: Replace tokens | |
uses: cschleiden/replace-tokens@v1 | |
with: | |
files: '["${{ github.workspace }}/generated/homebrew/falu.rb","${{ github.workspace }}/generated/scoop/falu.json"]' | |
- name: Upload Artifact (releases) | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/generated | |
name: releases-generated | |
retention-days: 1 | |
Release: | |
runs-on: ubuntu-latest | |
needs: [ DockerMerge, Checksum, Packaging ] | |
if: startsWith(github.ref, 'refs/tags/') | |
steps: | |
- name: Download Artifact (releases) | |
uses: actions/download-artifact@v4 | |
with: | |
path: ${{ github.workspace }}/releases | |
pattern: releases-* | |
merge-multiple: true | |
- name: Upload Release | |
uses: ncipollo/release-action@v1 | |
with: | |
# comma-separated values ('>' will make it a single line) | |
artifacts: > | |
${{ github.workspace }}/releases/checksum.txt, | |
${{ github.workspace }}/releases/falu-*.deb, | |
${{ github.workspace }}/releases/falu-*.rpm, | |
${{ github.workspace }}/releases/falu-*.tar.gz, | |
${{ github.workspace }}/releases/falu-*.zip | |
token: ${{ secrets.GITHUB_TOKEN }} | |
draft: true | |
allowUpdates: true | |
- name: Update homebrew tap repository | |
uses: dmnemec/copy_file_to_another_repo_action@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.RELEASING_GITHUB_TOKEN }} | |
with: | |
source_file: '${{ github.workspace }}/releases/homebrew/falu.rb' | |
destination_repo: 'faluapp/homebrew-falu-cli' | |
user_email: '[email protected]' | |
user_name: 'falu-ci' | |
commit_message: 'Update homebrew tap to ${{ needs.Packaging.outputs.BINARIES_VERSION }}' | |
- name: Update scoop bucket repository | |
uses: dmnemec/copy_file_to_another_repo_action@main | |
env: | |
API_TOKEN_GITHUB: ${{ secrets.RELEASING_GITHUB_TOKEN }} | |
with: | |
source_file: '${{ github.workspace }}/releases/scoop/falu.json' | |
destination_repo: 'faluapp/scoop-falu-cli' | |
user_email: '[email protected]' | |
user_name: 'falu-ci' | |
commit_message: 'Update scoop bucket to ${{ needs.Packaging.outputs.BINARIES_VERSION }}' |