aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: 0e4f08d0bab78593620e51ec0a259aeae2943ab0 (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
name: Release binaries

on:
  push:
    tags:
      - 'v*'

permissions:
  contents: write

env:
  PKGNAME: tomo

jobs:
  build-linux:
    strategy:
      matrix:
        arch:
          - x86_64
          - aarch64

        include:
          - arch: x86_64
            runner: ubuntu-latest
          - arch: aarch64
            runner: ubuntu-24.04-arm64

    runs-on: ${{ matrix.runner }}

    steps:
      - uses: actions/checkout@v4

      - name: Install deps
        run: |
          sudo apt-get update
          sudo apt-get install -y build-essential libgmp-dev libunistring-dev libgc-dev binutils

      - name: Build
        run: |
          make -j

      - name: Package
        run: |
          TAG=${GITHUB_REF_NAME}
          FILE=${PKGNAME}-linux-${{ matrix.arch }}.tar.gz
          tar -C build -czf "$FILE" ${PKGNAME}@${TAG}
          sha256sum "$FILE" > "$FILE.sha256"

      - name: Upload artifacts
        uses: actions/upload-artifact@v3
        with:
          name: linux-${{ matrix.arch }}
          path: |
            ${PKGNAME}-linux-${{ matrix.arch }}.tar.gz
            ${PKGNAME}-linux-${{ matrix.arch }}.tar.gz.sha256

  build-macos:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install deps
        run: |
          brew update
          brew install gmp libunistring bdw-gc llvm binutils

      - name: Build arm64
        run: |
          make -j

      - name: Package
        run: |
          TAG=${GITHUB_REF_NAME}
          tar -C build -czf ${PKGNAME}-macos-arm64.tar.gz ${PKGNAME}@${TAG}
          shasum -a 256 ${PKGNAME}-macos-arm64.tar.gz > ${PKGNAME}-macos-arm64.tar.gz.sha256

      - name: Upload artifacts
        uses: actions/upload-artifact@v3
        with:
          name: macos-arm64
          path: |
            ${PKGNAME}-macos-arm64.tar.gz
            ${PKGNAME}-macos-arm64.tar.gz.sha256

  upload-release:
    needs: [build-linux, build-macos]
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Download all artifacts
        uses: actions/download-artifact@v3
        with:
          path: release/

      - name: List artifacts
        run: ls -l release/

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: release/*

  aur:
    needs: upload-release
    runs-on: ubuntu-latest
    env:
      AUR_SSH_KEY: ${{ secrets.AUR_SSH_KEY }}
    steps:
      - uses: actions/checkout@v4

      - name: Install deps
        run: |
          sudo apt-get install -y pacman-contrib jq gh

      - name: Set up SSH
        run: |
          mkdir -p ~/.ssh
          echo "$AUR_SSH_KEY" > ~/.ssh/id_ed25519
          chmod 600 ~/.ssh/id_ed25519
          ssh-keyscan aur.archlinux.org >> ~/.ssh/known_hosts

      - name: Wait for release assets
        run: |
          TAG=${GITHUB_REF_NAME}
          for i in $(seq 60); do
            if gh release view "$TAG" --json assets \
              | jq -e '[ .assets[].name ] | index("tomo-linux-x86_64.tar.gz") and index("tomo-linux-aarch64.tar.gz")' >/dev/null
            then exit 0; fi
            sleep 10
          done
          echo "Timed out waiting for release assets"
          exit 1

      - name: Update PKGBUILD
        run: |
          TAG=${GITHUB_REF_NAME#v}
          sed -i "s/^_tomo_version=.*/_tomo_version=${TAG}/" PKGBUILD
          updpkgsums
          makepkg --printsrcinfo > .SRCINFO
          git config user.name "GitHub Actions"
          git config user.email "actions@github.com"
          git diff --quiet || git commit -am "Release v${TAG}"

      - name: Push to AUR
        run: |
          git push aur HEAD:master