👷 Distribute docker image
This commit is contained in:
1 parent
f413f632a1
commit
cafbdf3cbf
4 files changed
+99
-16
No files matched your search
@@ -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/login-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 }}
|
||||
commitDate=${{ 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
|
||||
@@ -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/')
|
||||
@@ -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: [test]
|
||||
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 }}
|
||||
@@ -1,15 +0,0 @@
|
||||
name: Publish to Homebrew
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
runs-on: macos-latest
|
||||
steps:
|
||||
- name: Update Homebrew formula
|
||||
uses: dawidd6/action-homebrew-bump-formula@v3
|
||||
with:
|
||||
token: ${{ secrets.RELEASE_PAT }}
|
||||
tag: ${{ github.event.release.tag_name }}
|
||||
org: eat-pray-ai
|
||||
formula: yutu
|
||||
+25
@@ -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"]
|
||||
Reference in new issue
Block a user