diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2025-12-23 15:28:05 -0500 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2025-12-23 15:28:05 -0500 |
| commit | 1a62de25c448d2661864ba25a98686ed506e66af (patch) | |
| tree | 383a5b62c8e3cdfefda84f16d60725b2725195d6 | |
| parent | 63a3d9d91b3998f5558e2e22023a2bdd4caf950c (diff) | |
Overhaul workflow to add automatic pushing to AUR and fix up mac builds
| -rw-r--r-- | .github/workflows/release.yml | 171 |
1 files changed, 95 insertions, 76 deletions
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2be7084e..0e4f08d0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -7,123 +7,142 @@ on: permissions: contents: write - packages: write + +env: + PKGNAME: tomo jobs: - linux-x86_64: - runs-on: ubuntu-latest + 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 \ - xxd \ - binutils + sudo apt-get install -y build-essential libgmp-dev libunistring-dev libgc-dev binutils - name: Build run: | - make clean make -j - name: Package run: | - TAG=${GITHUB_REF#refs/tags/} - tar -C build -czf tomo-linux-x86_64.tar.gz tomo@${TAG} - sha256sum tomo-linux-x86_64.tar.gz > tomo-linux-x86_64.tar.gz.sha256 + TAG=${GITHUB_REF_NAME} + FILE=${PKGNAME}-linux-${{ matrix.arch }}.tar.gz + tar -C build -czf "$FILE" ${PKGNAME}@${TAG} + sha256sum "$FILE" > "$FILE.sha256" - - name: Upload - uses: softprops/action-gh-release@v2 + - name: Upload artifacts + uses: actions/upload-artifact@v3 with: - files: | - tomo-linux-x86_64.tar.gz - tomo-linux-x86_64.tar.gz.sha256 + name: linux-${{ matrix.arch }} + path: | + ${PKGNAME}-linux-${{ matrix.arch }}.tar.gz + ${PKGNAME}-linux-${{ matrix.arch }}.tar.gz.sha256 - linux-aarch64: - runs-on: ubuntu-latest + build-macos: + runs-on: macos-latest 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 \ - xxd \ - binutils + brew update + brew install gmp libunistring bdw-gc llvm binutils - - name: Build + - name: Build arm64 run: | - make clean make -j - name: Package run: | - TAG=${GITHUB_REF#refs/tags/} - tar -C build -czf tomo-linux-aarch64.tar.gz tomo@${TAG} - sha256sum tomo-linux-aarch64.tar.gz > tomo-linux-aarch64.tar.gz.sha256 + 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 + - 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: | - tomo-linux-aarch64.tar.gz - tomo-linux-aarch64.tar.gz.sha256 + files: release/* - macos: - runs-on: macos-latest + 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: | - brew update - brew install gmp libunistring bdw-gc llvm binutils + sudo apt-get install -y pacman-contrib jq gh - - name: Build arm64 + - name: Set up SSH run: | - make clean - make -j \ - CC=clang \ - CFLAGS="-arch arm64" \ - LDFLAGS="-arch arm64" - mv build/tomo build/tomo-arm64 - - - name: Build x86_64 + 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: | - make clean - make -j \ - CC=clang \ - CFLAGS="-arch x86_64" \ - LDFLAGS="-arch x86_64" - mv build/tomo build/tomo-x86_64 - - - name: Create universal binary + 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: | - lipo -create \ - build/tomo-arm64 \ - build/tomo-x86_64 \ - -output build/tomo - lipo -info build/tomo - - - name: Package + 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: | - TAG=${GITHUB_REF#refs/tags/} - tar -C build -czf tomo-macos-universal.tar.gz tomo@${TAG} - shasum -a 256 tomo-macos-universal.tar.gz > tomo-macos-universal.tar.gz.sha256 - - - name: Upload - uses: softprops/action-gh-release@v2 - with: - files: | - tomo-macos-universal.tar.gz - tomo-macos-universal.tar.gz.sha256 + git push aur HEAD:master |
