|
| 1 | +name: Release Prebuilt Libraries |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: |
| 6 | + - published |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: Tag name to upload assets to, for example v1.0.0 |
| 11 | + required: true |
| 12 | + type: string |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: write |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-linux-x64: |
| 19 | + name: Build Linux x64 |
| 20 | + runs-on: ubuntu-24.04 |
| 21 | + steps: |
| 22 | + - uses: actions/checkout@v4 |
| 23 | + |
| 24 | + - name: Install build tools |
| 25 | + run: sudo apt-get update && sudo apt-get install -y curl autoconf automake libtool pkg-config git |
| 26 | + |
| 27 | + - name: Compile shared library |
| 28 | + run: bash build/compile-linux.sh |
| 29 | + |
| 30 | + - name: Create release archive |
| 31 | + run: tar -czf build/libpostal-linux-x64.tar.gz -C postalkit/libs/linux-x64 libpostal.so |
| 32 | + |
| 33 | + - name: Upload workflow artifact |
| 34 | + uses: actions/upload-artifact@v4 |
| 35 | + with: |
| 36 | + name: libpostal-linux-x64 |
| 37 | + path: build/libpostal-linux-x64.tar.gz |
| 38 | + if-no-files-found: error |
| 39 | + |
| 40 | + build-linux-arm64: |
| 41 | + name: Build Linux arm64 |
| 42 | + runs-on: ubuntu-24.04-arm |
| 43 | + steps: |
| 44 | + - uses: actions/checkout@v4 |
| 45 | + |
| 46 | + - name: Install build tools |
| 47 | + run: sudo apt-get update && sudo apt-get install -y curl autoconf automake libtool pkg-config git |
| 48 | + |
| 49 | + - name: Compile shared library |
| 50 | + run: bash build/compile-linux.sh |
| 51 | + |
| 52 | + - name: Create release archive |
| 53 | + run: tar -czf build/libpostal-linux-arm64.tar.gz -C postalkit/libs/linux-arm64 libpostal.so |
| 54 | + |
| 55 | + - name: Upload workflow artifact |
| 56 | + uses: actions/upload-artifact@v4 |
| 57 | + with: |
| 58 | + name: libpostal-linux-arm64 |
| 59 | + path: build/libpostal-linux-arm64.tar.gz |
| 60 | + if-no-files-found: error |
| 61 | + |
| 62 | + build-macos-x64: |
| 63 | + name: Build macOS x64 |
| 64 | + runs-on: macos-13 |
| 65 | + steps: |
| 66 | + - uses: actions/checkout@v4 |
| 67 | + |
| 68 | + - name: Install build tools |
| 69 | + run: brew install autoconf automake libtool pkg-config |
| 70 | + |
| 71 | + - name: Compile shared library |
| 72 | + run: bash build/compile-macos.sh |
| 73 | + |
| 74 | + - name: Create release archive |
| 75 | + run: tar -czf build/libpostal-macos-x64.tar.gz -C postalkit/libs/macos-x64 libpostal.dylib |
| 76 | + |
| 77 | + - name: Upload workflow artifact |
| 78 | + uses: actions/upload-artifact@v4 |
| 79 | + with: |
| 80 | + name: libpostal-macos-x64 |
| 81 | + path: build/libpostal-macos-x64.tar.gz |
| 82 | + if-no-files-found: error |
| 83 | + |
| 84 | + build-macos-arm64: |
| 85 | + name: Build macOS arm64 |
| 86 | + runs-on: macos-14 |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v4 |
| 89 | + |
| 90 | + - name: Install build tools |
| 91 | + run: brew install autoconf automake libtool pkg-config |
| 92 | + |
| 93 | + - name: Compile shared library |
| 94 | + run: bash build/compile-macos.sh |
| 95 | + |
| 96 | + - name: Create release archive |
| 97 | + run: tar -czf build/libpostal-macos-arm64.tar.gz -C postalkit/libs/macos-arm64 libpostal.dylib |
| 98 | + |
| 99 | + - name: Upload workflow artifact |
| 100 | + uses: actions/upload-artifact@v4 |
| 101 | + with: |
| 102 | + name: libpostal-macos-arm64 |
| 103 | + path: build/libpostal-macos-arm64.tar.gz |
| 104 | + if-no-files-found: error |
| 105 | + |
| 106 | + build-windows-x64: |
| 107 | + name: Build Windows x64 |
| 108 | + runs-on: windows-2022 |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v4 |
| 111 | + |
| 112 | + - name: Set up MSYS2 with MinGW |
| 113 | + uses: msys2/setup-msys2@v2 |
| 114 | + with: |
| 115 | + msystem: MINGW64 |
| 116 | + update: true |
| 117 | + install: >- |
| 118 | + base-devel |
| 119 | + mingw-w64-x86_64-toolchain |
| 120 | + mingw-w64-x86_64-autotools |
| 121 | + git |
| 122 | +
|
| 123 | + - name: Compile shared library |
| 124 | + shell: pwsh |
| 125 | + run: .\build\compile-windows.ps1 |
| 126 | + |
| 127 | + - name: Create release archive |
| 128 | + shell: pwsh |
| 129 | + run: Compress-Archive -Path postalkit\libs\windows-x64\postal.dll -DestinationPath build\libpostal-windows-x64.zip -Force |
| 130 | + |
| 131 | + - name: Upload workflow artifact |
| 132 | + uses: actions/upload-artifact@v4 |
| 133 | + with: |
| 134 | + name: libpostal-windows-x64 |
| 135 | + path: build/libpostal-windows-x64.zip |
| 136 | + if-no-files-found: error |
| 137 | + |
| 138 | + upload-release-assets: |
| 139 | + name: Upload Release Assets |
| 140 | + if: github.event_name == 'release' || github.event_name == 'workflow_dispatch' |
| 141 | + needs: |
| 142 | + - build-linux-x64 |
| 143 | + - build-linux-arm64 |
| 144 | + - build-macos-x64 |
| 145 | + - build-macos-arm64 |
| 146 | + - build-windows-x64 |
| 147 | + runs-on: ubuntu-latest |
| 148 | + steps: |
| 149 | + - name: Download workflow artifacts |
| 150 | + uses: actions/download-artifact@v4 |
| 151 | + with: |
| 152 | + path: dist |
| 153 | + merge-multiple: true |
| 154 | + |
| 155 | + - name: Generate SHA256 Checksums |
| 156 | + run: | |
| 157 | + cd dist |
| 158 | + for file in *; do |
| 159 | + sha256sum "$file" > "${file}.sha256" |
| 160 | + done |
| 161 | +
|
| 162 | + - name: Resolve target tag |
| 163 | + id: target |
| 164 | + shell: bash |
| 165 | + run: | |
| 166 | + if [ "${{ github.event_name }}" = "release" ]; then |
| 167 | + echo "tag=${{ github.event.release.tag_name }}" >> "$GITHUB_OUTPUT" |
| 168 | + else |
| 169 | + echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT" |
| 170 | + fi |
| 171 | +
|
| 172 | + - name: Attach assets to GitHub Release |
| 173 | + uses: softprops/action-gh-release@v2 |
| 174 | + with: |
| 175 | + tag_name: ${{ steps.target.outputs.tag }} |
| 176 | + files: | |
| 177 | + dist/libpostal-linux-x64.tar.gz |
| 178 | + dist/libpostal-linux-x64.tar.gz.sha256 |
| 179 | + dist/libpostal-linux-arm64.tar.gz |
| 180 | + dist/libpostal-linux-arm64.tar.gz.sha256 |
| 181 | + dist/libpostal-macos-x64.tar.gz |
| 182 | + dist/libpostal-macos-x64.tar.gz.sha256 |
| 183 | + dist/libpostal-macos-arm64.tar.gz |
| 184 | + dist/libpostal-macos-arm64.tar.gz.sha256 |
| 185 | + dist/libpostal-windows-x64.zip |
| 186 | + dist/libpostal-windows-x64.zip.sha256 |
| 187 | + fail_on_unmatched_files: true |
0 commit comments