summaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: ab4556674316f2912dbaae880fd7f275b3e738bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
name: Release

on:
  push:
    branches:
      - main

permissions:
  contents: write
  pull-requests: write

jobs:
  release-please:
    runs-on: ubuntu-latest
    outputs:
      release_created: ${{ steps.release.outputs.release_created }}
      tag_name: ${{ steps.release.outputs.tag_name }}
    steps:
      - uses: googleapis/release-please-action@v4
        id: release
        with:
          release-type: go

  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version: '1.25'
      - name: Install deps
        run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev xorg-dev
      - name: Test
        run: go test ./...
      - name: Vet
        run: go vet ./...

  build-linux:
    needs: [release-please, test]
    if: needs.release-please.outputs.release_created
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version: '1.25'
      - name: Install deps
        run: sudo apt-get update && sudo apt-get install -y libgl1-mesa-dev xorg-dev wget
      - name: Install Fyne
        run: go install fyne.io/tools/cmd/fyne@latest
      - name: Build
        run: go build -o shiv .
      - name: Download linuxdeploy
        run: wget -qO linuxdeploy https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage && chmod +x linuxdeploy
      - name: Build AppImage
        run: |
          mkdir -p AppDir/usr/bin AppDir/usr/lib AppDir/usr/share/applications AppDir/usr/share/icons/hicolor/256x256/apps
          cp shiv AppDir/usr/bin/
          cp assets/logo.png AppDir/usr/share/icons/hicolor/256x256/apps/shiv.png
          printf '[Desktop Entry]\nName=Shiv\nExec=shiv\nIcon=shiv\nType=Application\nCategories=Utility;\n' > AppDir/usr/share/applications/shiv.desktop
          ldd shiv | grep "=> /" | awk '{print $3}' | xargs -I{} cp -L {} AppDir/usr/lib/
          chmod +w AppDir/usr/lib/*.so*
          ARCH=x86_64 fhs-run ./linuxdeploy --appdir AppDir --output appimage
      - name: Upload AppImage
        uses: softprops/action-gh-release@v3
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: Shiv-x86_64.AppImage

  build-macos:
    needs: [release-please, test]
    if: needs.release-please.outputs.release_created
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version: '1.25'
      - name: Install Fyne
        run: go install fyne.io/tools/cmd/fyne@latest
      - name: Build arm64
        run: GOARCH=arm64 fyne package -os darwin
      - name: Move arm64 binary
        run: mv Shiv.app/Contents/MacOS/Shiv Shiv.app/Contents/MacOS/Shiv-arm64
      - name: Build amd64
        run: GOARCH=amd64 fyne package -os darwin
      - name: Move amd64 binary
        run: mv Shiv.app/Contents/MacOS/Shiv Shiv.app/Contents/MacOS/Shiv-amd64
      - name: Create universal binary
        run: |
          lipo -create \
            Shiv.app/Contents/MacOS/Shiv-arm64 \
            Shiv.app/Contents/MacOS/Shiv-amd64 \
            -output Shiv.app/Contents/MacOS/Shiv
          rm Shiv.app/Contents/MacOS/Shiv-arm64 Shiv.app/Contents/MacOS/Shiv-amd64
      - name: Zip app
        run: zip -r Shiv-macos.zip Shiv.app
      - name: Upload
        uses: softprops/action-gh-release@v3
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: Shiv-macos.zip

  build-windows:
    needs: [release-please, test]
    if: needs.release-please.outputs.release_created
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: actions/setup-go@v6
        with:
          go-version: '1.25'
      - name: Install deps
        run: sudo apt-get update && sudo apt-get install -y gcc-mingw-w64-x86-64 libgl1-mesa-dev xorg-dev
      - name: Install Fyne
        run: go install fyne.io/tools/cmd/fyne@latest
      - name: Build
        run: CC=x86_64-w64-mingw32-gcc GOOS=windows GOARCH=amd64 CGO_ENABLED=1 fyne package -os windows
      - name: Upload
        uses: softprops/action-gh-release@v3
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: Shiv.exe