feat(ci): auto upload to ghcr and release artifact

This commit is contained in:
nc
2026-06-10 04:43:13 +08:00
parent c725d40d80
commit 6b06cb03f8
3 changed files with 60 additions and 0 deletions
+35
View File
@@ -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 }}
+11
View File
@@ -0,0 +1,11 @@
builds:
- id: tslink
main: .
env:
- CGO_ENABLED=0
ldflags:
- -s
- -w
platforms:
- linux/amd64
- linux/arm64
+14
View File
@@ -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: