diff --git a/.github/actions/github-packages/action.yml b/.github/actions/github-packages/action.yml new file mode 100644 index 0000000..180b34c --- /dev/null +++ b/.github/actions/github-packages/action.yml @@ -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 }} + 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 diff --git a/.github/workflows/go-ossf-slsa3-publish.yml b/.github/workflows/go-ossf-slsa3-publish.yml index 8a86b6a..29a8433 100644 --- a/.github/workflows/go-ossf-slsa3-publish.yml +++ b/.github/workflows/go-ossf-slsa3-publish.yml @@ -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: [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 }} diff --git a/.github/workflows/homebrew-release.yml b/.github/workflows/homebrew-release.yml deleted file mode 100644 index 7aec4fa..0000000 --- a/.github/workflows/homebrew-release.yml +++ /dev/null @@ -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 diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..9083855 --- /dev/null +++ b/Dockerfile @@ -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"]