Skip to content

Commit

Permalink
Add Github Actions configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhammond committed Feb 29, 2024
1 parent c557094 commit a7c32c6
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 16 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

set -ex

go generate ./...

GOOS=${OS}
[ "$GOOS" = "macos" ] && GOOS=darwin
GOARCH="${ARCH}" GOOS="$GOOS" go build -tags netgo -o cftest ./cmd/cftest

mkdir -p build/cftest
cp README.md build/cftest
cp cftest build/cftest/cftest

cd build
tar -czf "cftest-${OS}-${ARCH}-${REF}.tgz" cftest
31 changes: 31 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build
on: [push]
jobs:
build:
name: Build
runs-on: ubuntu-22.04
strategy:
matrix:
os: ["macos", "linux"]
arch: ["arm64", "amd64"]
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.0'
- name: Test
run: go test -v ./...
- name: Build
env:
OS: ${{ matrix.os }}
ARCH: ${{ matrix.arch }}
REF: ${{ github.sha }}
run: "./.github/workflows/build.sh"
- name: Upload
uses: actions/upload-artifact@v4
with:
name: "cftest-${{matrix.os}}-${{matrix.arch}}-${{github.sha}}.tgz"
path: "build/cftest-${{matrix.os}}-${{matrix.arch}}-${{github.sha}}.tgz"
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Release
on:
push:
tags:
- "v*"
jobs:
create-release:
name: Create Release
runs-on: ubuntu-22.04
steps:
- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release create --repo ${{ github.repository }} "${GITHUB_REF#refs/tags/}"
build:
name: Build
needs: create-release
runs-on: ubuntu-22.04
strategy:
matrix:
os: ["macos", "linux"]
arch: ["arm64", "amd64"]
fail-fast: false
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22.0'
- name: Test
run: go test -v ./...
- name: Build
env:
OS: ${{ matrix.os }}
ARCH: ${{ matrix.arch }}
REF: ${{ github.sha }}
run: "./.github/workflows/build.sh"
- name: Upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "${GITHUB_REF#refs/tags/}" build/cftest-${{matrix.os}}-${{matrix.arch}}-${{github.sha}}.tgz
13 changes: 0 additions & 13 deletions Dockerfile

This file was deleted.

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ expected outputs. That's where cftest comes in.
[Cloudfront functions]: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-functions.html
[testfunction]: https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_TestFunction.html

## Installing
## Installation

Example build steps are included in the [Dockerfile](Dockerfile). Prebuilt
binaries and Docker images might be provided in the future.
Prebuilt binaries can be downloaded from from
[Github Releases](https://github.com/paulhammond/cftest/releases)

## Usage

Expand Down

0 comments on commit a7c32c6

Please sign in to comment.