From 6b06cb03f8232c9ae99600f1609ff0273ea7a7d7 Mon Sep 17 00:00:00 2001 From: nc Date: Wed, 10 Jun 2026 04:43:13 +0800 Subject: [PATCH] feat(ci): auto upload to ghcr and release artifact --- .github/workflows/build.yml | 35 +++++++++++++++++++++++++++++++++++ .ko.yaml | 11 +++++++++++ docker-compose.yml | 14 ++++++++++++++ 3 files changed, 60 insertions(+) create mode 100644 .ko.yaml create mode 100644 docker-compose.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 8a5e58d..2c603fb 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,6 +5,8 @@ on: branches: - master pull_request: + release: + types: [published] jobs: build: @@ -55,3 +57,36 @@ jobs: with: name: tslink-dev${{ steps.date.outputs.date }}-${{ matrix.goos }}_${{ matrix.goarch }} path: release/ + + container: + if: github.event_name == 'release' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v6 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: '1.26.3' + cache: true + + - name: Login to ghcr.io + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Install ko + run: go install github.com/google/ko@latest + + - name: Build and push container image + env: + KO_DOCKER_REPO: ghcr.io/${{ github.repository_owner }}/tslink + run: | + ko build --bare ./ --platform=all \ + -t latest \ + -t ${{ github.ref_name }} diff --git a/.ko.yaml b/.ko.yaml new file mode 100644 index 0000000..3222dd8 --- /dev/null +++ b/.ko.yaml @@ -0,0 +1,11 @@ +builds: + - id: tslink + main: . + env: + - CGO_ENABLED=0 + ldflags: + - -s + - -w + platforms: + - linux/amd64 + - linux/arm64 diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..aed8736 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,14 @@ +services: + tslink: + image: ghcr.io/saltedfishclub/tslink:latest + ports: + - "9000:9000" + - "25565:25565" + volumes: + - ./config.toml:/etc/tslink/config.toml:ro + - tslink_state:/var/lib/tslink + command: ["-c", "/etc/tslink/config.toml"] + restart: unless-stopped + +volumes: + tslink_state: