diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ab6f9b..df11b95 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -4,24 +4,29 @@ on: release: types: [published] +permissions: + contents: write + packages: write + jobs: - publish: + goreleaser: runs-on: ubuntu-latest - steps: - - name: install golang - uses: actions/setup-go@v5 - with: - go-version: 1.23.1 - - - name: checkout code - uses: actions/checkout@v4 - - - name: build assets - run: make release VERSION=${{ github.event.release.tag_name }} - - - name: gh login - run: echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token - - - name: upload assets to release - run: gh release upload ${{ github.event.release.tag_name }} dist/* + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-go@v5 + with: + go-version: 1.23.1 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: goreleaser/goreleaser-action@v6 + if: success() && startsWith(github.ref, 'refs/tags/') + with: + version: "~> v2" + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..71aaa0d --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,23 @@ +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +project_name: supercronic + +builds: + - env: [CGO_ENABLED=0] + goos: + - linux + - darwin + goarch: + - amd64 + - arm64 +archives: + - format: binary +kos: + - repository: ghcr.io/aptible/supercronic + tags: + - "{{.Version}}" + - latest + bare: true + preserve_import_paths: false + platforms: + - linux/amd64 + - linux/arm64 diff --git a/Makefile b/Makefile index 7df77ee..fe5649c 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,4 @@ vulncheck: build fmt: gofmt -l -w ${GOFILES_NOVENDOR} -.PHONY: release -release: - ./build.sh ${VERSION} - .DEFAULT_GOAL := test diff --git a/README.md b/README.md index 1c7ab16..8d24ab2 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ Supercronic is a crontab-compatible job runner, designed specifically to run in containers. - + ## Why Supercronic? ## @@ -63,7 +63,30 @@ running cron jobs in containers**. ### Download -The easiest way to install Supercronic is to download a pre-built binary. +#### Run in Docker + +To run supersonic as a Docker container, you can use the following command: + +```bash +docker run -v /path/to/crontab:/etc/crontab -it ghcr.io/aptible/supercronic /etc/crontab +``` + +#### Include in Dockerfile + +To include Supercronic in your Dockerfile, you can use the following: + +```Dockerfile +FROM ubuntu:latest + +COPY --from=ghcr.io/aptible/supercronic:latest /ko-app/supercronic /usr/local/bin/supercronic + +COPY ./path/to/crontab /etc/custom-crontab + +ENTRYPOINT ["/usr/local/bin/supercronic", "/etc/custom-crontab"] +``` + +#### Download the latest release +You can as well download a pre-built binary. Navigate to [the releases page][releases], and grab the build that suits your system. The releases include example `Dockerfile` stanzas to install @@ -71,7 +94,8 @@ Supercronic that you can easily include in your own `Dockerfile` or adjust as needed. Note: If you are unsure which binary is right for you, try -`supercronic-linux-amd64`. +`supercronic_{{vesion}}_linux_amd64`. + ### Build diff --git a/build.sh b/build.sh deleted file mode 100755 index 9e75a6d..0000000 --- a/build.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -set -x - -mkdir -p dist -export GOOS="linux" -export CGO_ENABLED=0 -VERSION=${1:-$(git describe --tags --always --dirty)} -for arch in amd64 386 arm arm64; do GOARCH="$arch" go build -ldflags="-X 'main.Version=$VERSION'" && file supercronic | grep 'statically linked' && mv supercronic "dist/supercronic-${GOOS}-${arch}"; done -pushd dist -ls -lah * -file * -sha1sum * -sha256sum * -popd