Skip to content

Commit

Permalink
Add build static binary workflow
Browse files Browse the repository at this point in the history
Add build strategy in workflow
  • Loading branch information
muzi502 committed Nov 23, 2021
1 parent 47b8082 commit 938d65e
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/build-static-binary.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
name: Build static binary
on:
push:
tags:
- 'v*'
env:
BUILDER_IMAGE: ghcr.io/k8sli/nixos-nix:v2.3.12

jobs:
build:
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- arch: amd64
- arch: arm64
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Set up QEMU
uses: docker/setup-qemu-action@v1

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Build skopeo binary file
run: |
MANIFEST=$(skopeo --insecure-policy --override-arch ${{ matrix.arch }} inspect docker://${BUILDER_IMAGE} --raw)
DIGEST=$(jq -r '.manifests[]|select(.platform.architecture == "${{ matrix.arch }}" ) | .digest' <<<"${MANIFEST}")
docker run --rm -t -v $PWD:/build ${BUILDER_IMAGE}@${DIGEST} \
sh -c "cd /build && nix build -f nix && cp ./result/bin/skopeo skopeo-linux-${{ matrix.arch }}"
sha256sum skopeo-linux-${{ matrix.arch }} > skopeo-linux-${{ matrix.arch }}.sha256sum.txt
- name: Release and upload binary file
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
files: |
skopeo-linux-${{ matrix.arch }}
skopeo-linux-${{ matrix.arch }}.sha256sum.txt

0 comments on commit 938d65e

Please sign in to comment.