diff --git a/.github/workflows/build.sh b/.github/workflows/build.sh new file mode 100755 index 0000000..bdce9f2 --- /dev/null +++ b/.github/workflows/build.sh @@ -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 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..92bd29e --- /dev/null +++ b/.github/workflows/build.yml @@ -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" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..94352f0 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 diff --git a/Dockerfile b/Dockerfile deleted file mode 100644 index 0ab4a55..0000000 --- a/Dockerfile +++ /dev/null @@ -1,13 +0,0 @@ -FROM golang:1.16.5-alpine3.14@sha256:3361eb3ffa949cf0cf60c13778697183a22684e0a0a5edf9ccb9d2f1ae4da873 as BUILD - -WORKDIR /build -COPY . . -RUN go generate ./... && \ - go build -tags netgo -o /usr/bin/cftest ./cmd/cftest - -FROM alpine:3.14.0@sha256:234cb88d3020898631af0ccbbcca9a66ae7306ecd30c9720690858c1b007d2a0 - -COPY --from=build /usr/bin/cftest /usr/bin/cftest - -ENTRYPOINT ["/usr/bin/cftest"] - diff --git a/README.md b/README.md index dfac3bd..31a96e4 100644 --- a/README.md +++ b/README.md @@ -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