diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 96dd0e3..30b0243 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -66,3 +66,26 @@ jobs: earthly --ci +release \ --RELEASE_VERSION=${GITHUB_REF:10} \ --GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }} + + - name: Put back the git branch into git (Earthly uses it for tagging) + run: | + branch="" + if [ -n "$GITHUB_HEAD_REF" ]; then + branch="$GITHUB_HEAD_REF" + else + branch="${GITHUB_REF##*/}" + fi + git checkout -b "$branch" || true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ vars.GHCR_USERNAME }} + password: ${{ secrets.GHCR_TOKEN }} + + - name: Build and push docker image + run: | + earthly --ci --push +image \ + --TARGET_DOCKER_REGISTRY=ghcr.io/librepod \ + --RELEASE_VERSION=${{ github.ref_name }} diff --git a/Earthfile b/Earthfile index fec5d26..e158e75 100644 --- a/Earthfile +++ b/Earthfile @@ -1,5 +1,7 @@ VERSION 0.7 +ARG --global TARGET_DOCKER_REGISTRY + FROM golang:1.18-bullseye validate-pr: @@ -11,7 +13,7 @@ validate-pr: SAVE ARTIFACT build /build AS LOCAL ./build multi-build: - ARG --required RELEASE_VERSION + ARG RELEASE_VERSION=latest ENV PLATFORMS="darwin/amd64 darwin/arm64 windows/amd64 linux/amd64 linux/arm64" ENV VERSION_INJECT="github.com/librepod/frp-port-keeper/main.Version" ENV OUTPUT_PATH_FORMAT="./build/${RELEASE_VERSION}/{{.OS}}/{{.Arch}}/frp-port-keeper" @@ -68,6 +70,17 @@ release: SAVE ARTIFACT build /build AS LOCAL ./build +image: + FROM golang:1.18-alpine3.17 + LABEL org.opencontainers.image.source="https://github.com/librepod/frp-port-keeper" + ARG RELEASE_VERSION=latest + COPY +multi-build/build /build + WORKDIR /build + EXPOSE 8080 + RUN ls -al /build + CMD ["/build/frp-port-keeper"] + SAVE IMAGE --push ${TARGET_DOCKER_REGISTRY}/frp-port-keeper:$RELEASE_VERSION + validate-mr: # Smoke test the application # TODO: set proper validation