|
| 1 | +name: Build, Test and Release |
| 2 | + |
| 3 | +on: push |
| 4 | + |
| 5 | +permissions: read-all |
| 6 | + |
| 7 | +# update in build.yml and codeql.yml at same time |
| 8 | +env: |
| 9 | + PROTOC_VERSION: 21.3 |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + runs-on: ubuntu-latest |
| 14 | + |
| 15 | + env: |
| 16 | + PROTOC: protoc-release/bin/protoc |
| 17 | + PROTOC_INC: protoc-release/include |
| 18 | + PROTOC_PLATFORM: linux-x86_64 |
| 19 | + |
| 20 | + steps: |
| 21 | + |
| 22 | + - uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - uses: actions/setup-node@v3 |
| 25 | + with: |
| 26 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 27 | + node-version: 16 |
| 28 | + cache: ${{ !env.ACT && 'npm' || '' }} # cache API not available in ACT |
| 29 | + |
| 30 | + - uses: bazelbuild/setup-bazelisk@v2 |
| 31 | + with: |
| 32 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 33 | + |
| 34 | + - name: Install Protoc |
| 35 | + run: | |
| 36 | + echo "Fetching protoc" |
| 37 | + curl --header 'Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' \ |
| 38 | + -L https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${PROTOC_PLATFORM}.zip \ |
| 39 | + --output protoc-release.zip |
| 40 | + unzip protoc-release.zip -d protoc-release |
| 41 | + rm protoc-release.zip |
| 42 | +
|
| 43 | + - run: npm ci |
| 44 | + |
| 45 | + - run: npm test |
| 46 | + |
| 47 | + - run: npm run build |
| 48 | + |
| 49 | + - uses: actions/upload-artifact@v3 |
| 50 | + with: |
| 51 | + name: js |
| 52 | + path: | |
| 53 | + google-protobuf.js |
| 54 | + google |
| 55 | +
|
| 56 | + package: |
| 57 | + needs: build |
| 58 | + runs-on: ${{ matrix.os }} |
| 59 | + |
| 60 | + strategy: |
| 61 | + fail-fast: false |
| 62 | + matrix: |
| 63 | +# for now I'm disabling linux building as we don't have the tooling to support it |
| 64 | +# os: [ ubuntu-latest ] |
| 65 | +# cpu: |
| 66 | +# - k8 # this build 'linux-x86_64', is currently working but not useful without the other architectures |
| 67 | +# would need some kind of CROSSTOOL chain to build the other architectures |
| 68 | +# or we'd have to use the https://github.com/uraimo/run-on-arch-action (which lacks support for x86_32) to build these |
| 69 | +# - x86_32 |
| 70 | +# - systemz |
| 71 | +# - aarch64 |
| 72 | +# - ppc64 |
| 73 | + include: |
| 74 | +# to ensure backwards compatibility as long as possible, use earliest versions of OSs available on Github Actions |
| 75 | + - os: windows-2019 |
| 76 | + cpu: x64_windows |
| 77 | + bazel_target: dist_zip |
| 78 | + - os: windows-2019 |
| 79 | + cpu: x64_x86_windows |
| 80 | + bazel_target: dist_zip |
| 81 | +# disabling Mac OS releases for now since they are working through existing build process |
| 82 | +# - os: macos-11 |
| 83 | +# cpu: darwin_arm64 |
| 84 | +# - os: macos-11 |
| 85 | +# cpu: darwin_x86_64 |
| 86 | + |
| 87 | + steps: |
| 88 | + - uses: actions/checkout@v3 |
| 89 | + |
| 90 | + - uses: actions/download-artifact@v3 |
| 91 | + if: ${{ !env.ACT }} |
| 92 | + with: |
| 93 | + name: js |
| 94 | + |
| 95 | + - uses: bazelbuild/setup-bazelisk@v2 |
| 96 | + with: |
| 97 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 98 | + |
| 99 | + - run: mkdir out |
| 100 | + |
| 101 | + # setup-bazelisk fails when running in ACT because the cache is not available so we need to ignore to let the bazel step run |
| 102 | + - if: success() || env.ACT && failure() |
| 103 | + run: bazel build --cpu=${{ matrix.cpu }} ${{ matrix.bazel_target || 'dist_all' }} |
| 104 | + shell: bash |
| 105 | + |
| 106 | + # need to copy to output directory as `bazel-bin` is a symlink and cannot be read by the actions/upload-artifact action |
| 107 | + - run: cp bazel-bin/protobuf-javascript-* out/ |
| 108 | + |
| 109 | + - uses: actions/upload-artifact@v3 |
| 110 | + with: |
| 111 | + name: releases |
| 112 | + path: out |
| 113 | + |
| 114 | + release: |
| 115 | + needs: package |
| 116 | + if: startsWith(github.ref, 'refs/tags/') |
| 117 | + |
| 118 | + runs-on: ubuntu-latest |
| 119 | + permissions: |
| 120 | + contents: write |
| 121 | + |
| 122 | + steps: |
| 123 | + - uses: actions/download-artifact@v3 |
| 124 | + with: |
| 125 | + name: releases |
| 126 | + |
| 127 | + - name: Release |
| 128 | + uses: svenstaro/upload-release-action@v2 |
| 129 | + with: |
| 130 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 131 | + file: protobuf-javascript-* |
| 132 | + file_glob: true |
| 133 | + tag: ${{ github.ref }} |
| 134 | + overwrite: true |
0 commit comments