Skip to content

fix(ci): update to match bandsnatch #40

fix(ci): update to match bandsnatch

fix(ci): update to match bandsnatch #40

Workflow file for this run

name: CI
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
tags:
- v*
jobs:
build-linux:
strategy:
matrix:
platform:
- name: x86_64
target: amd64
runs-on: ubuntu-latest
- name: aarch64
target: arm64
runs-on: [self-hosted, linux, ARM64]
runs-on: ${{ matrix.platform.runs-on }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# - name: Cache Docker layers
# uses: actions/cache@v2
# with:
# path: /tmp/.buildx-cache
# key:
# "${{ runner.os }}-buildx-${{ matrix.platform.name }}-${{ github.sha
# }}"
# restore-keys: |
# ${{ runner.os }}-buildx-${{ matrix.platform.name }}
- name: Login to GitHub Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build in Docker ${{ matrix.platform.name }}
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
platforms: linux/${{ matrix.platform.target }}
push: false
load: true
# TODO: set :latest and versioned tag, on new version
# should I even bother pushing?
# ovyerus/gfh:nightly
tags: |
ghcr.io/ovyerus/gfh:nightly
# cache-from: type=local,src=/tmp/.buildx-cache
# cache-to: type=local,dest=/tmp/.buildx-cache
- name: Extract binaries
run: |
id=$(docker create --platform=linux/${{ matrix.platform.target }} ghcr.io/ovyerus/gfh:nightly)
docker cp $id:/gfh/gfh ./gfh
docker cp $id:/gfh/gfh-keygen ./gfh-keygen
docker rm -v $id
- name: Upload ${{ matrix.platform.name }}
uses: actions/upload-artifact@v2
with:
name: gfh-linux-${{ matrix.platform.name }}
path: |
./gfh
./gfh-keygen
build-macos:
runs-on: macos-11
strategy:
matrix:
target:
- x86_64
- aarch64
steps:
- uses: actions/checkout@v2
- name: Install target
uses: actions-rs/toolchain@v1
with:
toolchain: stable-apple-darwin
target: ${{ matrix.target }}-apple-darwin
override: true
profile: minimal
- uses: Swatinem/rust-cache@v2
if: "!startsWith(github.ref, 'refs/tags/')"
with:
key: ${{ matrix.target }}
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target ${{ matrix.target }}-apple-darwin
- uses: actions/upload-artifact@v2
with:
name: gfh-macos-${{ matrix.target }}
path: |
target/${{ matrix.target }}-apple-darwin/release/gfh
target/${{ matrix.target }}-apple-darwin/release/gfh-keygen
build-windows:
runs-on: windows-2022
steps:
- uses: actions/checkout@v2
- name: Install target
uses: actions-rs/toolchain@v1
with:
toolchain: stable-x86_64-pc-windows-msvc
target: x86_64-pc-windows-msvc
override: true
profile: minimal
- uses: Swatinem/rust-cache@v2
if: "!startsWith(github.ref, 'refs/tags/')"
- name: Build
uses: actions-rs/cargo@v1
with:
command: build
args: --release --target x86_64-pc-windows-msvc
- uses: actions/upload-artifact@v2
with:
name: "gfh-windows-x86_64-msvc"
path: |
target/x86_64-pc-windows-msvc/release/gfh.exe
target/x86_64-pc-windows-msvc/release/gfh-keygen.exe
# TODO: clippy lints & rustfmt
create-release:
runs-on: ubuntu-20.04
if: startsWith(github.ref, 'refs/tags/')
needs:
- build-linux
- build-macos
- build-windows
steps:
- uses: actions/checkout@v3
- uses: actions/download-artifact@v3
- name: Rename files
run: |
mkdir out && cd out
declare -a arr=(
"windows-x86_64"
"macos-x86_64"
"macos-aarch64"
"linux-x86_64"
"linux-aarch64"
)
for target in "${arr[@]}"
do
inputfiles="../gfh-$target/*"
if [[ "$target" == *windows* ]]; then
filename="gfh-$target.zip"
7z -y a $filename $inputfiles
else
filename="gfh-$target.tar.gz"
tar czf $filename $inputfiles
fi
sha256sum "$filename" >> "checksums.txt"
done
- name: Create draft release
uses: softprops/action-gh-release@v1
with:
body: Update the description for the release!
draft: true
files: ./out/*
# - name: Update Homebrew tap
# uses: mislav/bump-homebrew-formula-action@v2
# with:
# formula-name: gfh
# homebrew-tap: Ovyerus/homebrew-tap
# env:
# COMMITTER_TOKEN: ${{ secrets.TAP_COMMITTER_TOKEN }}