v0.23.5 #39
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build Release Binaries | |
on: | |
release: | |
types: [created] | |
workflow_dispatch: {} | |
jobs: | |
build: | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
include: | |
- name: linux_amd64 | |
artifact: ibazel_linux_amd64 | |
os: ubuntu-latest | |
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:linux_amd64 | |
cpu_flag: | |
ext: "" | |
- name: linux_arm64 | |
artifact: ibazel_linux_arm64 | |
os: ubuntu-latest | |
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:linux_arm64 | |
cpu_flag: | |
ext: "" | |
- name: windows_amd64 | |
artifact: ibazel_windows_amd64.exe | |
os: ubuntu-latest | |
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:windows_amd64 | |
cpu_flag: | |
ext: ".exe" | |
- name: darwin_amd64 | |
artifact: ibazel_darwin_amd64 | |
os: macos-latest | |
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:darwin_amd64_cgo | |
cpu_flag: | |
ext: "" | |
- name: darwin_arm64 | |
artifact: ibazel_darwin_arm64 | |
os: macos-latest | |
build_flags: --platforms=@io_bazel_rules_go//go/toolchain:darwin_arm64_cgo | |
# TODO: temporary workaround, remove this in the future. | |
# Right now, without the flag, GitHub actions build would link to the "darwin_amd64" go_sdk toolchain and fail the build. | |
# related issue: https://github.com/fsnotify/fsevents/issues/50 | |
# also general info on Bazel platforms: https://bazel.build/concepts/platforms#migration | |
cpu_flag: --cpu=darwin_arm64 | |
ext: "" | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Build ibazel | |
run: bazel build //cmd/ibazel:ibazel --config release ${{ matrix.build_flags }} ${{ matrix.cpu_flag }} | |
- name: Copy binary | |
run: cp $(bazel info ${{ matrix.cpu_flag }} bazel-bin)/cmd/ibazel/ibazel_/ibazel${{ matrix.ext }} ${{ matrix.artifact }} | |
- name: Upload binary | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.name }} | |
path: ${{ matrix.artifact }} | |
- name: Upload Release Asset | |
id: upload-release-asset | |
uses: actions/upload-release-asset@v1 | |
if: ${{ github.event.release.upload_url }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
# this hook param can means we can only use this flow when triggered by a release, not manually | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ${{ matrix.artifact }} | |
asset_name: ${{ matrix.artifact }} | |
asset_content_type: application/octet-stream | |
release_npm: | |
runs-on: ubuntu-latest | |
needs: [build] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: actions/download-artifact@v3 | |
with: | |
path: ./npm-staging/bin | |
- name: Prepare ibazel binaries | |
working-directory: ./npm-staging/bin | |
run: | | |
mv darwin_amd64/ibazel_darwin_amd64 darwin_amd64/ibazel | |
mv darwin_arm64/ibazel_darwin_arm64 darwin_arm64/ibazel | |
mv linux_amd64/ibazel_linux_amd64 linux_amd64/ibazel | |
mv linux_arm64/ibazel_linux_arm64 linux_arm64/ibazel | |
mv windows_amd64/ibazel_windows_amd64.exe windows_amd64/ibazel.exe | |
chmod 755 */ibazel* | |
- name: Create NPM Package | |
run: | | |
pwd | |
find . | |
cp "README.md" "npm-staging/README.md" | |
cp "release/npm/index.js" "npm-staging/index.js" | |
cp ".npmrc" "npm-staging/.npmrc" | |
bazel run --config="release" "//release/npm" -- "${PWD}/CONTRIBUTORS" > "npm-staging/package.json" | |
# Setup .npmrc file to publish to npm | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Publish NPM Package | |
if: ${{ github.event.release.upload_url }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
working-directory: ./npm-staging | |
run: | | |
cat ~/.npmrc || echo "Didn't find .npmrc" | |
echo -n "Publishing to NPM as " | |
grep "version" < "package.json" | |
find . && cat package.json && npm install && echo "Publishing to npm..." && npm publish |