|
| 1 | +name: Build Binaries |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*' # Only build on tag pushes for releases |
| 7 | + workflow_dispatch: # Allow manual triggering of the build |
| 8 | + |
| 9 | +jobs: |
| 10 | + build: |
| 11 | + runs-on: ${{ matrix.os }} |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [ubuntu-latest, macos-latest] |
| 15 | + include: |
| 16 | + - os: ubuntu-latest |
| 17 | + binary_name: sqlwrite-linux |
| 18 | + - os: macos-latest |
| 19 | + binary_name: sqlwrite-mac |
| 20 | + |
| 21 | + steps: |
| 22 | + - name: Checkout repository |
| 23 | + uses: actions/checkout@v3 |
| 24 | + |
| 25 | + - name: Install dependencies |
| 26 | + run: | |
| 27 | + if [[ "$RUNNER_OS" == "Linux" ]]; then |
| 28 | + sudo apt-get update |
| 29 | + sudo apt-get install -y make |
| 30 | + fi |
| 31 | +
|
| 32 | + - name: Build with Make |
| 33 | + run: make |
| 34 | + |
| 35 | + - name: Rename binary |
| 36 | + run: | |
| 37 | + mv sqlwrite ${{ matrix.binary_name }} |
| 38 | +
|
| 39 | + - name: Upload binary as artifact |
| 40 | + uses: actions/upload-artifact@v3 |
| 41 | + with: |
| 42 | + name: ${{ matrix.binary_name }} |
| 43 | + path: ${{ matrix.binary_name }} |
| 44 | + |
| 45 | + release: |
| 46 | + needs: build |
| 47 | + runs-on: ubuntu-latest |
| 48 | + if: startsWith(github.ref, 'refs/tags/') |
| 49 | + steps: |
| 50 | + - name: Download artifacts |
| 51 | + uses: actions/download-artifact@v3 |
| 52 | + with: |
| 53 | + name: sqlwrite-linux |
| 54 | + path: . |
| 55 | + |
| 56 | + - name: Download macOS artifact |
| 57 | + uses: actions/download-artifact@v3 |
| 58 | + with: |
| 59 | + name: sqlwrite-mac |
| 60 | + path: . |
| 61 | + |
| 62 | + - name: Upload release binaries |
| 63 | + uses: actions/upload-release-asset@v1 |
| 64 | + env: |
| 65 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 66 | + with: |
| 67 | + upload_url: ${{ github.event.release.upload_url }} |
| 68 | + asset_path: ./sqlwrite-linux |
| 69 | + asset_name: sqlwrite-linux |
| 70 | + label: "Linux binary" |
| 71 | + |
| 72 | + - name: Upload macOS binary |
| 73 | + uses: actions/upload-release-asset@v1 |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + with: |
| 77 | + upload_url: ${{ github.event.release.upload_url }} |
| 78 | + asset_path: ./sqlwrite-mac |
| 79 | + asset_name: sqlwrite-mac |
| 80 | + label: "macOS binary" |
0 commit comments