blob: 116422ed344d0f93c2d924078cbdf7383fcd862a [file]
---
name: Release Finalize
on:
push:
branches:
- main
paths:
# Only trigger for new releases
- "version.bzl"
defaults:
run:
shell: bash
jobs:
release:
if: ${{ github.repository_owner == 'bazelbuild' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: |
# Get current release version
git fetch origin &> /dev/null
RELEASE_VERSION=$(cat version.bzl | grep VERSION | sed 's/VERSION = "//' | sed 's/"//')
echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV
# Get release candidate number
echo "RELEASE_CANDIDATE_NUMBER=$(git tag -l | grep "${RELEASE_VERSION}" | wc -l | xargs || true)" >> $GITHUB_ENV
- run: |
# Ensure there is at least 1 release candidate in the environment
if [[ -z "${RELEASE_CANDIDATE_NUMBER}" ]]; then
exit 1
elif [[ "${RELEASE_CANDIDATE_NUMBER}" -eq "0" ]]; then
exit 1
fi
- run: |
# Download all artifacts from the release candidate
TARGETS=(
aarch64-apple-darwin
aarch64-unknown-linux-gnu
x86_64-apple-darwin
x86_64-pc-windows-gnu
x86_64-unknown-linux-gnu
)
for triple in ${TARGETS[@]}; do
if [[ "${triple}" == *"windows"* ]]; then
ext=".exe"
else
ext=""
fi
resolver="${ARTIFACT_DIR}/${triple}/release/crate_universe_resolver${ext}"
mkdir -p "$(dirname "${resolver}")"
url="${ARTIFACT_URL}/crate_universe_resolver-${triple}${ext}"
echo "Downloading '${url}' to '${resolver}'"
curl --fail -Lo "${resolver}" "${url}"
sha256="$(shasum --algorithm 256 "${resolver}" | awk '{ print $1 }')"
if [[ -z "$(grep "\"${triple}\": \"${sha256}\"" ${{ github.workspace }}/crate_universe/private/defaults.bzl)" ]]; then
echo "Unexpected sha256 value from `${url}`: got ${sha256}, expected value in `defaults.bzl`"
exit 1
fi
done
env:
ARTIFACT_URL: https://github.com/${{ github.repository_owner }}/rules_rust/releases/download/${{env.RELEASE_VERSION}}rc-${{ env.RELEASE_CANDIDATE_NUMBER }}
ARTIFACT_DIR: ${{ github.workspace }}/crate_universe/private/bootstrap/bin
- uses: actions/create-release@v1
id: rules_rust_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
tag_name: ${{env.RELEASE_VERSION}}
release_name: ${{env.RELEASE_VERSION}}
body: ${{env.RELEASE_VERSION}}
commitish: ${{ github.base_ref }}
# There must be a upload action for each platform triple we create
- name: "Upload aarch64-apple-darwin"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_rust_release.outputs.upload_url }}
asset_name: crate_universe_resolver-aarch64-apple-darwin
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/aarch64-apple-darwin/release/crate_universe_resolver
asset_content_type: application/octet-stream
- name: "Upload aarch64-unknown-linux-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_rust_release.outputs.upload_url }}
asset_name: crate_universe_resolver-aarch64-unknown-linux-gnu
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/aarch64-unknown-linux-gnu/release/crate_universe_resolver
asset_content_type: application/octet-stream
- name: "Upload x86_64-apple-darwin"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_rust_release.outputs.upload_url }}
asset_name: crate_universe_resolver-x86_64-apple-darwin
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/x86_64-apple-darwin/release/crate_universe_resolver
asset_content_type: application/octet-stream
- name: "Upload x86_64-pc-windows-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_rust_release.outputs.upload_url }}
asset_name: crate_universe_resolver-x86_64-pc-windows-gnu.exe
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/x86_64-pc-windows-gnu/release/crate_universe_resolver.exe
asset_content_type: application/octet-stream
- name: "Upload x86_64-unknown-linux-gnu"
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.rules_rust_release.outputs.upload_url }}
asset_name: crate_universe_resolver-x86_64-unknown-linux-gnu
asset_path: ${{ github.workspace }}/crate_universe/private/bootstrap/bin/x86_64-unknown-linux-gnu/release/crate_universe_resolver
asset_content_type: application/octet-stream