name: release_grpc on: release: # Docs: types: - prereleased - released jobs: build: name: Build for ${{ matrix.os }} (${{ matrix.arch }}, ${{ matrix.compiler }}) runs-on: ubuntu-latest strategy: fail-fast: false matrix: os: [ windows, darwin ] # linux, darwin, windows compiler: [ gcc ] # gcc, musl-gcc archiver: [ zip ] # tar, zip arch: [ amd64 ] # amd64, 386 include: - os: linux compiler: gcc archiver: tar arch: amd64 #---------- - os: linux compiler: gcc archiver: tar arch: arm64 #---------- - os: freebsd compiler: gcc archiver: tar arch: amd64 #---------- - os: darwin compiler: gcc archiver: tar arch: arm64 #---------- - os: '' compiler: musl-gcc # more info: archiver: zip arch: amd64 steps: - name: Set up Go uses: actions/setup-go@v3 with: go-version: 1.20 - name: Check out code uses: actions/checkout@v3 with: repository: 'roadrunner-server/grpc' - name: Install musl if: matrix.compiler == 'musl-gcc' run: sudo apt-get install -y musl-tools - name: Download dependencies run: cd protoc_plugins && go mod download - name: Generate builder values id: values run: | echo "version=$(echo ${GITHUB_REF##*/} | sed -e 's/^[vV ]*//')" >> $GITHUB_OUTPUT echo "timestamp=$(echo $(date +%FT%T%z))" >> $GITHUB_OUTPUT echo "binary-name=$(echo $(echo protoc-gen-php-grpc`[ ${{ matrix.os }} = 'windows' ] && echo '.exe'`))" >> $GITHUB_OUTPUT if [ ${{ matrix.os }} == "windows" ]; then echo "sign-cert-name=protoc-gen-php-grpc.exe.asc" >> $GITHUB_OUTPUT else echo "sign-cert-name=protoc-gen-php-grpc.asc" >> $GITHUB_OUTPUT fi - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v5 with: gpg_private_key: ${{ secrets.GPG_SIGNING_KEY }} passphrase: ${{ secrets.GPG_PASS }} git_user_signingkey: true git_commit_gpgsign: false - name: Compile binary file env: GOOS: ${{ matrix.os }} GOARCH: ${{ matrix.arch }} CC: ${{ matrix.compiler }} CGO_ENABLED: 0 LDFLAGS: >- -s run: | cd protoc_plugins && go build -trimpath -ldflags "$LDFLAGS" -o "../${{ steps.values.outputs.binary-name }}" protoc-gen-php-grpc/main.go stat "../${{ steps.values.outputs.binary-name }}" gpg --detach-sign --armor "../${{ steps.values.outputs.binary-name }}" - name: Generate distributive directory name id: dist-dir run: > echo "name=$(echo protoc-gen-php-grpc-${{ steps.values.outputs.version }}-$( [ ${{ matrix.os }} != '' ] && echo '${{ matrix.os }}' || echo 'unknown' )$( [ ${{ matrix.compiler }} = 'musl-gcc' ] && echo '-musl' ))-${{ matrix.arch }}" >> $GITHUB_OUTPUT - name: Generate distributive archive name id: dist-arch run: > echo "name=$(echo ${{ steps.dist-dir.outputs.name }}.$( case ${{ matrix.archiver }} in zip) echo 'zip';; tar) echo 'tar.gz';; *) exit 10; esac ))" >> $GITHUB_OUTPUT - name: Create distributive run: | mkdir ${{ steps.dist-dir.outputs.name }} mv "./${{ steps.values.outputs.binary-name }}" "./${{ steps.values.outputs.sign-cert-name }}" ./${{ steps.dist-dir.outputs.name }}/ - name: Pack distributive using tar if: matrix.archiver == 'tar' run: tar -zcf "${{ steps.dist-arch.outputs.name }}" "${{ steps.dist-dir.outputs.name }}" - name: Pack distributive using zip if: matrix.archiver == 'zip' run: zip -r -q "${{ steps.dist-arch.outputs.name }}" "${{ steps.dist-dir.outputs.name }}" - name: Upload artifact uses: actions/upload-artifact@v3 with: name: ${{ steps.dist-dir.outputs.name }} path: ${{ steps.dist-arch.outputs.name }} if-no-files-found: error retention-days: 30 - name: Upload binaries to release uses: svenstaro/upload-release-action@v2 with: repo_token: ${{ secrets.GITHUB_TOKEN }} file: ${{ steps.dist-arch.outputs.name }} asset_name: ${{ steps.dist-arch.outputs.name }} tag: ${{ github.ref }}