Skip to content

fix: PdfView render 添加 canvas 属性,修复 pdfjs-dist v5 TS 编译错误 #39

fix: PdfView render 添加 canvas 属性,修复 pdfjs-dist v5 TS 编译错误

fix: PdfView render 添加 canvas 属性,修复 pdfjs-dist v5 TS 编译错误 #39

Workflow file for this run

name: Build & Release
on:
push:
branches: [main]
tags: ['v*']
pull_request:
branches: [main]
env:
BINARY_NAME: nowen-reader
DOCKER_IMAGE: cropflre/nowen-reader
jobs:
# ============================================================
# Test & Lint
# ============================================================
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Download dependencies
run: go mod download
- name: Vet
run: go vet ./...
- name: Test
run: go test ./... -race -v
# ============================================================
# Build binaries (on tag push)
# ============================================================
build:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
strategy:
matrix:
include:
- goos: linux
goarch: amd64
suffix: linux-amd64
- goos: linux
goarch: arm64
suffix: linux-arm64
- goos: darwin
goarch: amd64
suffix: darwin-amd64
- goos: darwin
goarch: arm64
suffix: darwin-arm64
- goos: windows
goarch: amd64
suffix: windows-amd64.exe
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build
env:
GOOS: ${{ matrix.goos }}
GOARCH: ${{ matrix.goarch }}
CGO_ENABLED: 0
run: |
VERSION=${GITHUB_REF#refs/tags/}
BUILD_TIME=$(date -u +%Y-%m-%dT%H:%M:%SZ)
GIT_COMMIT=$(git rev-parse --short HEAD)
go build -ldflags="-s -w \
-X main.Version=${VERSION} \
-X main.BuildTime=${BUILD_TIME} \
-X main.GitCommit=${GIT_COMMIT}" \
-o ${{ env.BINARY_NAME }}-${{ matrix.suffix }} \
./cmd/server
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.BINARY_NAME }}-${{ matrix.suffix }}
path: ${{ env.BINARY_NAME }}-${{ matrix.suffix }}
# ============================================================
# Docker build & push (on tag push)
# ============================================================
docker:
needs: test
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version
id: version
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
VERSION=${{ steps.version.outputs.VERSION }}
BUILD_TIME=${{ github.event.head_commit.timestamp }}
GIT_COMMIT=${{ github.sha }}
tags: |
${{ env.DOCKER_IMAGE }}:${{ steps.version.outputs.VERSION }}
${{ env.DOCKER_IMAGE }}:latest
cache-from: type=gha
cache-to: type=gha,mode=max
# ============================================================
# Create GitHub Release (on tag push)
# ============================================================
release:
needs: [build, docker]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts/
- name: Create Release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: artifacts/**/*