LabCodeHub öffentliche Ansicht
Anmelden
Küpper / Quildrop öffentlich
Branch: main
Quildrop / .github / workflows / build-and-release.yml
Verlauf Rohdaten
R Rüdiger Küpper fix: new version with themes + multi arch builds
b56ed7e0 vor 14 Tagen
.github/workflows/build-and-release.yml 145 Zeilen · 3.8 KB · YAML
1
name: Build and Release
2
3
on:
4
  push:
5
    tags:
6
      - 'v*'
7
  workflow_dispatch:
8
    inputs:
9
      tag:
10
        description: 'Release tag (e.g. v1.2.3)'
11
        required: true
12
13
permissions:
14
  contents: write
15
16
env:
17
  BINARY_NAME: quilldrop
18
19
jobs:
20
  build:
21
    runs-on: ubuntu-latest
22
    strategy:
23
      fail-fast: false
24
      matrix:
25
        include:
26
          - goos: linux
27
            goarch: amd64
28
          - goos: linux
29
            goarch: arm64
30
          - goos: linux
31
            goarch: arm
32
            goarm: '7'
33
          - goos: darwin
34
            goarch: amd64
35
          - goos: darwin
36
            goarch: arm64
37
          - goos: windows
38
            goarch: arm64
39
40
    steps:
41
      - name: Checkout
42
        uses: actions/checkout@v6
43
44
      - name: Setup Go
45
        uses: actions/setup-go@v6
46
        with:
47
          go-version-file: go.mod
48
          cache: true
49
50
      - name: Build static binary
51
        env:
52
          GOOS: ${{ matrix.goos }}
53
          GOARCH: ${{ matrix.goarch }}
54
          GOARM: ${{ matrix.goarm }}
55
          CGO_ENABLED: '0'
56
        run: |
57
          set -euo pipefail
58
59
          SUFFIX="${GOOS}-${GOARCH}"
60
          if [ -n "${GOARM}" ]; then
61
            SUFFIX="${SUFFIX}v${GOARM}"
62
          fi
63
64
          BIN="${BINARY_NAME}-${SUFFIX}"
65
          if [ "${GOOS}" = "windows" ]; then
66
            BIN="${BIN}.exe"
67
          fi
68
69
          go build -trimpath -ldflags="-s -w" -o "${BIN}" .
70
71
          mkdir -p dist
72
          if [ "${GOOS}" = "windows" ]; then
73
            zip "dist/${BINARY_NAME}-${SUFFIX}.zip" "${BIN}"
74
          else
75
            tar -czf "dist/${BINARY_NAME}-${SUFFIX}.tar.gz" "${BIN}"
76
          fi
77
78
      - name: Generate checksum
79
        env:
80
          SUFFIX: ${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && format('v{0}', matrix.goarm) || '' }}
81
        run: |
82
          cd dist
83
          sha256sum * > checksums-${SUFFIX}.txt
84
          cat checksums-${SUFFIX}.txt
85
86
      - name: Upload artifact
87
        uses: actions/upload-artifact@v7
88
        with:
89
          name: ${{ env.BINARY_NAME }}-${{ matrix.goos }}-${{ matrix.goarch }}${{ matrix.goarm && format('v{0}', matrix.goarm) || '' }}
90
          path: dist/*
91
          if-no-files-found: error
92
93
  release:
94
    needs: build
95
    runs-on: ubuntu-latest
96
    steps:
97
      - name: Checkout
98
        uses: actions/checkout@v6
99
        with:
100
          path: src
101
102
      - name: Download all artifacts
103
        uses: actions/download-artifact@v8
104
        with:
105
          path: artifacts
106
          merge-multiple: true
107
108
      - name: Merge checksums
109
        run: |
110
          cd artifacts
111
          cat checksums-*.txt > checksums.txt
112
          rm checksums-*.txt
113
          echo "=== checksums.txt ==="
114
          cat checksums.txt
115
116
      # Templates are no longer embedded in the binary — ship the default theme
117
      # so a new site can be bootstrapped without cloning the repository.
118
      - name: Package default theme
119
        run: |
120
          set -euo pipefail
121
          tar -czf artifacts/${BINARY_NAME}-theme-default.tar.gz -C src themes/default
122
          cd artifacts
123
          sha256sum ${BINARY_NAME}-theme-default.tar.gz >> checksums.txt
124
125
      - name: Determine tag
126
        id: tag
127
        run: |
128
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
129
            echo "version=${{ github.event.inputs.tag }}" >> "$GITHUB_OUTPUT"
130
          else
131
            echo "version=${GITHUB_REF#refs/tags/}" >> "$GITHUB_OUTPUT"
132
          fi
133
134
      - name: List release assets
135
        run: ls -la artifacts/
136
137
      - name: Create GitHub Release
138
        env:
139
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
140
        run: |
141
          gh release create "${{ steps.tag.outputs.version }}" \
142
            --repo "${{ github.repository }}" \
143
            --title "${{ steps.tag.outputs.version }}" \
144
            --generate-notes \
145
            artifacts/*