|
| 1 | +name: protoc-gen-grafbase-subgraph-release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + tags: |
| 7 | + - 'protoc-gen-grafbase-subgraph-*' |
| 8 | + |
| 9 | +permissions: |
| 10 | + contents: write |
| 11 | + |
| 12 | +env: |
| 13 | + CARGO_PROFILE_DEV_DEBUG: 0 |
| 14 | + CARGO_PROFILE_TEST_DEBUG: 0 |
| 15 | + CARGO_TERM_COLOR: 'always' |
| 16 | + |
| 17 | +jobs: |
| 18 | + build-and-upload: |
| 19 | + name: Build and upload artifact |
| 20 | + strategy: |
| 21 | + fail-fast: false |
| 22 | + matrix: |
| 23 | + platform: |
| 24 | + [ |
| 25 | + { 'target': 'x86_64-unknown-linux-musl', 'runner': 'depot-ubuntu-24.04-8' }, |
| 26 | + { 'target': 'aarch64-unknown-linux-musl', 'runner': 'depot-ubuntu-24.04-arm-8' }, |
| 27 | + { 'target': 'aarch64-apple-darwin', 'runner': 'depot-macos-latest' }, |
| 28 | + { 'target': 'x86_64-pc-windows-msvc', 'runner': 'depot-windows-2022-8' }, |
| 29 | + ] |
| 30 | + runs-on: ${{ matrix.platform.runner }} |
| 31 | + steps: |
| 32 | + - name: Checkout code |
| 33 | + uses: actions/checkout@v4 |
| 34 | + |
| 35 | + - name: Install Rust |
| 36 | + uses: ./.github/actions/install-rust |
| 37 | + with: |
| 38 | + target: ${{ matrix.platform.target }} |
| 39 | + |
| 40 | + - name: Install musl-tools |
| 41 | + if: ${{ contains(matrix.platform.target, 'linux') }} |
| 42 | + shell: bash |
| 43 | + run: | |
| 44 | + sudo apt-get install musl musl-tools |
| 45 | + # This seems like a horrible hack that might come back to bite, but lets see! |
| 46 | + sudo ln -s /bin/g++ /bin/musl-g++ |
| 47 | + sudo ln -s /bin/g++ /bin/aarch64-linux-musl-g++ |
| 48 | +
|
| 49 | + - name: Build binaries |
| 50 | + shell: bash |
| 51 | + run: | |
| 52 | + cargo build -p protoc-gen-grafbase-subgraph --release |
| 53 | +
|
| 54 | + - name: Prepare binary (Unix) |
| 55 | + if: matrix.platform.target != 'x86_64-pc-windows-msvc' |
| 56 | + run: | |
| 57 | + cd target/release |
| 58 | + tar -czf protoc-gen-grafbase-subgraph-${{ matrix.platform.target }}.tar.gz protoc-gen-grafbase-subgraph |
| 59 | +
|
| 60 | + - name: Prepare binary (Windows) |
| 61 | + if: matrix.platform.target == 'x86_64-pc-windows-msvc' |
| 62 | + run: | |
| 63 | + cd target/release |
| 64 | + 7z a protoc-gen-grafbase-subgraph-${{ matrix.platform.target }}.zip protoc-gen-grafbase-subgraph.exe |
| 65 | +
|
| 66 | + - name: Upload assets (Unix) |
| 67 | + if: matrix.platform.target != 'x86_64-pc-windows-msvc' |
| 68 | + uses: actions/upload-artifact@v4 |
| 69 | + with: |
| 70 | + name: protoc-gen-grafbase-subgraph-${{ matrix.platform.target }} |
| 71 | + path: target/release/protoc-gen-grafbase-subgraph-${{ matrix.platform.target }}.tar.gz |
| 72 | + |
| 73 | + - name: Upload assets (Windows) |
| 74 | + if: matrix.platform.target == 'x86_64-pc-windows-msvc' |
| 75 | + uses: actions/upload-artifact@v4 |
| 76 | + with: |
| 77 | + name: protoc-gen-grafbase-subgraph-${{ matrix.platform.target }} |
| 78 | + path: target/release/protoc-gen-grafbase-subgraph-${{ matrix.platform.target }}.zip |
| 79 | + |
| 80 | + create-release: |
| 81 | + name: Create GitHub release |
| 82 | + needs: build-and-upload |
| 83 | + runs-on: ubuntu-latest |
| 84 | + steps: |
| 85 | + - name: Checkout code |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Get version from tag |
| 89 | + id: get_version |
| 90 | + run: echo "VERSION=${GITHUB_REF#refs/tags/protoc-gen-grafbase-subgraph-}" >> $GITHUB_OUTPUT |
| 91 | + |
| 92 | + - name: Download all artifacts |
| 93 | + uses: actions/download-artifact@v4 |
| 94 | + with: |
| 95 | + path: artifacts |
| 96 | + |
| 97 | + - name: Create GitHub Release |
| 98 | + id: create_release |
| 99 | + uses: softprops/action-gh-release@da05d552573ad5aba039eaac05058a918a7bf631 # v2 |
| 100 | + with: |
| 101 | + draft: false |
| 102 | + prerelease: false |
| 103 | + files: | |
| 104 | + artifacts/protoc-gen-grafbase-subgraph-x86_64-unknown-linux-musl/protoc-gen-grafbase-subgraph-x86_64-unknown-linux-musl.tar.gz |
| 105 | + artifacts/protoc-gen-grafbase-subgraph-aarch64-unknown-linux-musl/protoc-gen-grafbase-subgraph-aarch64-unknown-linux-musl.tar.gz |
| 106 | + artifacts/protoc-gen-grafbase-subgraph-aarch64-apple-darwin/protoc-gen-grafbase-subgraph-aarch64-apple-darwin.tar.gz |
| 107 | + artifacts/protoc-gen-grafbase-subgraph-x86_64-pc-windows-msvc/protoc-gen-grafbase-subgraph-x86_64-pc-windows-msvc.zip |
0 commit comments