.github/workflows/release.yml #57
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: Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
inputs: | |
revision: | |
description: 'Tag or revision to build binaries for' | |
type: string | |
required: true | |
create_release: | |
description: 'Should publish the binary or not' | |
required: true | |
default: 'false' | |
jobs: | |
build-and-upload-artifacts: | |
name: 'Build and upload artifacts' | |
strategy: | |
matrix: | |
include: | |
- platform: 'ubuntu-22.04' | |
container: 'gcc:9.5.0-buster' | |
config: 'dev' | |
- platform: 'ubuntu-22.04' | |
container: 'gcc:9.5.0-buster' | |
config: 'release' | |
# NOTE: GitHub-hosted runners for macOS are x86_64 only | |
# https://github.com/github/roadmap/issues/528 | |
- platform: 'macos-12' | |
container: '' | |
config: 'release' | |
# Seeing an inexplicable | |
# ld: file not found: external/llvm_toolchain_llvm/lib/clang/15.0.7/lib/darwin/libclang_rt.asan_osx_dynamic.dylib | |
# when running the dev build in in GitHub Actions | |
runs-on: ${{ matrix.platform }} | |
container: ${{ matrix.container }} | |
env: | |
TAG: ${{ github.event.ref }} | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'π Check version' | |
run: | | |
set -euo pipefail | |
if [[ "${TAG:-}" == v* ]]; then | |
TAG_LIKE="$TAG" | |
else | |
TAG_LIKE="$(grep '## v' CHANGELOG.md | head -n 1 | cut -d ' ' -f 2)" | |
fi | |
NEW_VERSION="${TAG_LIKE/v/}" ./tools/version_check.sh | |
- name: 'π Install Bazelisk' | |
run: | | |
if ! command -v bazelisk; then | |
if [ "$RUNNER_OS" == "Windows" ]; then | |
choco install bazelisk | |
elif [ "$RUNNER_OS" == "Linux" ]; then | |
curl -L https://github.com/bazelbuild/bazelisk/releases/download/v1.16.0/bazelisk-linux-amd64 > /usr/local/bin/bazel | |
chmod +x /usr/local/bin/bazel | |
else | |
sudo npm install -g @bazel/bazelisk | |
fi | |
fi | |
- id: auth | |
name: 'π Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
workload_identity_provider: ${{ secrets.GCP_IDENTITY_PROVIDER }} | |
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }} | |
create_credentials_file: true | |
- name: 'π§ Build scip-clang' | |
run: | | |
# Stop Windows from converting the // to / | |
# https://github.com/bazelbuild/bazel/commit/866ecc8c3d5e0b899e3f0c9c6b2265f16daae842 | |
# https://stackoverflow.com/a/34386471 | |
export MSYS2_ARG_CONV_EXCL="*" | |
if [ "$RUNNER_OS" == "macOS" ]; then | |
export BAZEL_MEM="13G" | |
else # if [ "$RUNNER_OS" == "Linux" ]; then | |
export BAZEL_MEM="6G" | |
fi | |
{ | |
echo "startup --host_jvm_args=-Xmx$BAZEL_MEM" | |
} > ci.bazelrc | |
# Comment out the 'upload log' bit below for debugging | |
SUFFIX="" | |
if [ "$CONFIG" == "release" ]; then | |
if [ "$(uname -s)" == "Linux" ]; then | |
SUFFIX="-linux" | |
fi | |
fi | |
bazel build //indexer:scip-clang --config="$CONFIG$SUFFIX" # --execution_log_binary_file=log | |
if [ "$RUNNER_OS" == "Linux" ]; then | |
echo "--- GLIBC VERSIONS ---" | |
objdump -T bazel-bin/indexer/scip-clang | grep GLIBC | sed 's/.*GLIBC_\([.0-9]*\).*/\1/g' | sort -Vu | |
echo "----------------------" | |
fi | |
env: | |
CONFIG: ${{ matrix.config }} | |
- name: 'π Identify OS' | |
run: echo "OS=$(uname -s | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV" | |
# - name: 'πͺ΅ Upload log' | |
# uses: actions/upload-artifact@v3 | |
# with: | |
# name: ${{ env.OS }}-${{ matrix.config }}-build-log | |
# path: log | |
- name: ${{ format('πͺ Rename binary ({0})', matrix.config) }} | |
run: | | |
SUFFIX="-dev" | |
if [ "$CONFIG" == "release" ]; then | |
SUFFIX="" | |
fi | |
outBinaryPath="scip-clang${SUFFIX}-$(uname -m)-$OS" | |
cp bazel-bin/indexer/scip-clang "$outBinaryPath" | |
echo "outBinaryPath=$outBinaryPath" >> "$GITHUB_ENV" | |
echo "suffix=$SUFFIX" >> "$GITHUB_ENV" | |
env: | |
OS: ${{ env.OS }} | |
CONFIG: ${{ matrix.config }} | |
- name: ${{ format('π¦ Store binary ({0})', matrix.config) }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ matrix.platform }}-${{ matrix.config }}-release-artifacts | |
path: ${{ env.outBinaryPath }} | |
create-release: | |
name: 'Create release' | |
if: github.event_name != 'workflow_dispatch' || inputs.create_release | |
needs: build-and-upload-artifacts | |
runs-on: 'ubuntu-20.04' | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'π Create Release' | |
run: | | |
REV="$INPUT_REVISION" | |
if [ "$TRIGGER" != "workflow_dispatch" ]; then | |
REV="${GITHUB_REF/refs\/tags\//}" | |
fi | |
TEMPLATE="$(< .github/workflows/release-template.md)" | |
echo "${TEMPLATE//TAG_PLACEHOLDER/$REV}" > notes | |
gh release create "$REV" --title "scip-clang $REV" --notes-file notes | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TRIGGER: ${{ github.event_name }} | |
INPUT_REVISION: ${{ inputs.revision }} | |
# Download everything to avoid spelling out the different | |
# platforms here. | |
- name: 'π₯ Download all artifacts' | |
uses: actions/download-artifact@v3 | |
- name: 'π€ Upload artifacts for release' | |
run: gh release upload "${GITHUB_REF/refs\/tags\//}" ./*-release-artifacts/* | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |