Skip to content

Commit

Permalink
👷 Distribute docker image
Browse files Browse the repository at this point in the history
  • Loading branch information
OpenWaygate committed Jun 5, 2024
1 parent f413f63 commit 789c9f9
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 16 deletions.
47 changes: 47 additions & 0 deletions .github/actions/github-packages/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release to GitHub Packages
description: Release to GitHub Packages

inputs:
version:
description: 'The version of the package'
required: true

runs:
using: composite
steps:
- uses: actions/checkout@v4
- id: ldflags
shell: bash
run: |
echo "commit-date=$(git log -1 --date='format:%Y-%m-%d/%H.%M.%S' --pretty=%cd)" >> "$GITHUB_OUTPUT"
echo "commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/#-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}
- id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
- id: push
uses: docker/build-push-action@v5
with:
context: .
target: yutu
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
provenance: true
build-args: |
version=${{ inputs.version }}
commit=${{ steps.ldflags.outputs.commit }}
commit-date=${{ steps.ldflags.outputs.commit-date }}
# - uses: actions/attest-build-provenance@v1
# with:
# subject-name: ghcr.io/${{ github.repository }}
# subject-digest: ${{ steps.push.outputs.digest }}
# push-to-registry: true
28 changes: 27 additions & 1 deletion .github/workflows/go-ossf-slsa3-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
with:
subject-path: '${{ github.workspace }}/yutu-${{ matrix.artifact }}'

winget-release:
winget:
needs: [build]
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -113,3 +113,29 @@ jobs:
identifier: eat-pray-ai.yutu
installers-regex: '\.exe$' # Only .exe files
token: ${{ secrets.RELEASE_PAT }}

homebrew:
needs: [build]
runs-on: macos-latest
if: false
steps:
- uses: dawidd6/action-homebrew-bump-formula@v3
with:
token: ${{ secrets.RELEASE_PAT }}
tag: ${{ github.event.release.tag_name }}
org: eat-pray-ai
formula: yutu

github-package:
needs: [build]
runs-on: ubuntu-latest
# if: startsWith(github.ref, 'refs/tags/')
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- uses: eat-pray-ai/yutu/.github/actions/github-packages@main
with:
version: ${{ github.event.release.tag_name }}
15 changes: 0 additions & 15 deletions .github/workflows/homebrew-release.yml

This file was deleted.

25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:alpine as builder
ARG commit
ARG commitDate
ARG version

ENV MOD="github.com/eat-pray-ai/yutu/cmd"
WORKDIR /app
COPY . .

RUN Version="${MOD}.Version=${version}" \
Commit="${MOD}.Commit=${commit}" \
CommitDate="${MOD}.CommitDate=${commitDate}" \
Os="${MOD}.Os=linux" \
Arch="${MOD}.Arch=$(go env GOARCH)" \
ldflags="-s -X ${Version} -X ${Commit} -X ${CommitDate} -X ${Os} -X ${Arch}" \
&& export ldflags \
&& go mod download \
&& go build -ldflags "${ldflags}" -o yutu .

FROM alpine:latest as yutu

COPY --from=builder /app/yutu /usr/local/bin/yutu
RUN chmod +x /usr/local/bin/yutu

ENTRYPOINT ["/usr/local/bin/yutu"]

0 comments on commit 789c9f9

Please # to comment.