| 1 | name: Debian Packages |
| 2 | |
| 3 | on: |
| 4 | workflow_dispatch: |
| 5 | push: |
| 6 | tags: |
| 7 | - "ver.*" |
| 8 | |
| 9 | concurrency: |
| 10 | group: ${{ github.workflow }}-${{ github.ref }} |
| 11 | cancel-in-progress: true |
| 12 | |
| 13 | jobs: |
| 14 | build-amd64: |
| 15 | runs-on: ubuntu-24.04 |
| 16 | steps: |
| 17 | - uses: actions/checkout@v5 |
| 18 | with: |
| 19 | fetch-depth: 0 |
| 20 | |
| 21 | - name: Install build dependencies |
| 22 | run: | |
| 23 | sudo apt-get update |
| 24 | sudo apt-get install -y --no-install-recommends \ |
| 25 | debhelper cmake ninja-build pkg-config doxygen \ |
| 26 | libmarisa-dev rapidjson-dev libtclap-dev \ |
| 27 | googletest libgtest-dev |
| 28 | |
| 29 | - name: Build amd64 packages |
| 30 | env: |
| 31 | DIST_DIR: ${{ github.workspace }}/dist |
| 32 | BUILD_MODE: all |
| 33 | run: bash scripts/build-deb-packages.sh |
| 34 | |
| 35 | - uses: actions/upload-artifact@v4 |
| 36 | with: |
| 37 | name: deb-amd64 |
| 38 | path: dist/*.deb |
| 39 | |
| 40 | build-arm64: |
| 41 | runs-on: ubuntu-24.04 |
| 42 | steps: |
| 43 | - uses: actions/checkout@v5 |
| 44 | |
| 45 | - name: Set up arm64 cross-compilation environment |
| 46 | run: | |
| 47 | sudo rm -f /etc/apt/sources.list |
| 48 | sudo find /etc/apt/sources.list.d -maxdepth 1 \ |
| 49 | \( -name '*.list' -o -name '*.sources' \) -exec rm -f {} + |
| 50 | cat <<'EOF' | sudo tee /etc/apt/sources.list.d/opencc-cross.sources >/dev/null |
| 51 | Types: deb |
| 52 | URIs: http://archive.ubuntu.com/ubuntu |
| 53 | Suites: noble noble-updates noble-backports |
| 54 | Components: main restricted universe multiverse |
| 55 | Architectures: amd64 |
| 56 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 57 | |
| 58 | Types: deb |
| 59 | URIs: http://security.ubuntu.com/ubuntu |
| 60 | Suites: noble-security |
| 61 | Components: main restricted universe multiverse |
| 62 | Architectures: amd64 |
| 63 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 64 | |
| 65 | Types: deb |
| 66 | URIs: http://ports.ubuntu.com/ubuntu-ports |
| 67 | Suites: noble noble-updates noble-backports noble-security |
| 68 | Components: main restricted universe multiverse |
| 69 | Architectures: arm64 |
| 70 | Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg |
| 71 | EOF |
| 72 | sudo dpkg --add-architecture arm64 |
| 73 | sudo apt-get update |
| 74 | sudo apt-get install -y --no-install-recommends \ |
| 75 | debhelper cmake ninja-build pkg-config \ |
| 76 | crossbuild-essential-arm64 \ |
| 77 | libmarisa-dev:arm64 rapidjson-dev libtclap-dev \ |
| 78 | googletest libgtest-dev |
| 79 | |
| 80 | - name: Build arm64 packages |
| 81 | env: |
| 82 | DIST_DIR: ${{ github.workspace }}/dist |
| 83 | BUILD_MODE: any-only |
| 84 | TARGET_ARCH: arm64 |
| 85 | run: bash scripts/build-deb-packages.sh |
| 86 | |
| 87 | - uses: actions/upload-artifact@v4 |
| 88 | with: |
| 89 | name: deb-arm64 |
| 90 | path: dist/*.deb |
| 91 | |
| 92 | assemble: |
| 93 | needs: [build-amd64, build-arm64] |
| 94 | runs-on: ubuntu-24.04 |
| 95 | permissions: |
| 96 | contents: write |
| 97 | steps: |
| 98 | - uses: actions/checkout@v5 |
| 99 | |
| 100 | - uses: actions/download-artifact@v4 |
| 101 | with: |
| 102 | name: deb-amd64 |
| 103 | path: dist/ |
| 104 | |
| 105 | - uses: actions/download-artifact@v4 |
| 106 | with: |
| 107 | name: deb-arm64 |
| 108 | path: dist/ |
| 109 | |
| 110 | - name: Determine version |
| 111 | id: version |
| 112 | run: | |
| 113 | VERSION=$(dpkg-parsechangelog \ |
| 114 | -l packaging/debian/debian/changelog -S version) |
| 115 | echo "value=$VERSION" >> "$GITHUB_OUTPUT" |
| 116 | |
| 117 | - name: Assemble zip with checksums |
| 118 | run: | |
| 119 | cd dist |
| 120 | sha256sum ./*.deb > SHA256SUMS |
| 121 | zip "opencc-${{ steps.version.outputs.value }}-deb.zip" ./*.deb SHA256SUMS |
| 122 | |
| 123 | - uses: actions/upload-artifact@v4 |
| 124 | with: |
| 125 | name: opencc-deb-${{ steps.version.outputs.value }} |
| 126 | path: dist/opencc-*.zip |
| 127 | |
| 128 | - name: Upload to GitHub release |
| 129 | if: startsWith(github.ref, 'refs/tags/') |
| 130 | env: |
| 131 | GH_TOKEN: ${{ github.token }} |
| 132 | run: | |
| 133 | tag="${{ github.ref_name }}" |
| 134 | for i in $(seq 1 30); do |
| 135 | gh release view "$tag" --json isDraft > /dev/null 2>&1 && break |
| 136 | echo "Waiting for release $tag to be created ($i/30)..." |
| 137 | sleep 10 |
| 138 | done |
| 139 | gh release upload "$tag" \ |
| 140 | "dist/opencc-${{ steps.version.outputs.value }}-deb.zip" \ |
| 141 | --clobber |