1*ef3a692cSMatthias Maennich#!/bin/bash 2*ef3a692cSMatthias Maennich 3*ef3a692cSMatthias Maennichif [[ ! -f WORKSPACE ]] ; then 4*ef3a692cSMatthias Maennich echo 'You must run this command from the top of the workspace.' 5*ef3a692cSMatthias Maennich exit 1 6*ef3a692cSMatthias Maennichfi 7*ef3a692cSMatthias Maennich 8*ef3a692cSMatthias Maennichif [[ ! -f version.bzl ]] ; then 9*ef3a692cSMatthias Maennich version.bzl is missing. 10*ef3a692cSMatthias Maennich exit 1 11*ef3a692cSMatthias Maennichfi 12*ef3a692cSMatthias Maennichversion=$(sed -n -e 's/^version *= *"\(.*\)".*$/\1/p' version.bzl) 13*ef3a692cSMatthias Maennich 14*ef3a692cSMatthias Maennich# tar on macos builds a file with different checksums each time. 15*ef3a692cSMatthias Maennichif [[ $(uname) != 'Linux' ]] ; then 16*ef3a692cSMatthias Maennich echo 'You must run this command from a linux machine.' 17*ef3a692cSMatthias Maennich exit 1 18*ef3a692cSMatthias Maennichfi 19*ef3a692cSMatthias Maennich 20*ef3a692cSMatthias Maennich 21*ef3a692cSMatthias Maennichdist_file="/tmp/platforms-${version}.tar.gz" 22*ef3a692cSMatthias Maennichtar czf "$dist_file" BUILD LICENSE MODULE.bazel WORKSPACE WORKSPACE.bzlmod version.bzl cpu os host 23*ef3a692cSMatthias Maennichsha256=$(shasum -a256 "$dist_file" | cut -d' ' -f1) 24*ef3a692cSMatthias Maennich 25*ef3a692cSMatthias Maennichpath="github.com/bazelbuild/platforms/releases/download/$version/platforms-$version.tar.gz" 26*ef3a692cSMatthias Maennichcat <<INP 27*ef3a692cSMatthias Maennich 28*ef3a692cSMatthias Maennich 29*ef3a692cSMatthias Maennich1. Create a new release using the tag $version 30*ef3a692cSMatthias Maennich2. Copy/paste the text below into the release description field. 31*ef3a692cSMatthias Maennich3. Upload $dist_file as an artifact. 32*ef3a692cSMatthias Maennich4. Copy $dist_file to the mirror site. 33*ef3a692cSMatthias Maennich5. Create the release. 34*ef3a692cSMatthias Maennich6. Update Bazel distdir_deps.bzl to point to this new release. See the readme. 35*ef3a692cSMatthias Maennich 36*ef3a692cSMatthias Maennich=============== CUT HERE =============== 37*ef3a692cSMatthias Maennich**WORKSPACE setup** 38*ef3a692cSMatthias Maennich 39*ef3a692cSMatthias Maennich\`\`\` 40*ef3a692cSMatthias Maennichload("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 41*ef3a692cSMatthias Maennichhttp_archive( 42*ef3a692cSMatthias Maennich name = "platforms", 43*ef3a692cSMatthias Maennich urls = [ 44*ef3a692cSMatthias Maennich "https://mirror.bazel.build/${path}", 45*ef3a692cSMatthias Maennich "https://${path}", 46*ef3a692cSMatthias Maennich ], 47*ef3a692cSMatthias Maennich sha256 = "$sha256", 48*ef3a692cSMatthias Maennich) 49*ef3a692cSMatthias Maennich\`\`\` 50*ef3a692cSMatthias Maennich=============== CUT HERE =============== 51*ef3a692cSMatthias Maennich 52*ef3a692cSMatthias MaennichUse this to update Bazel's distdir_deps.bzl 53*ef3a692cSMatthias Maennich 54*ef3a692cSMatthias Maennich 55*ef3a692cSMatthias Maennich "archive": "platforms-$version.tar.gz", 56*ef3a692cSMatthias Maennich "sha256": "$sha256", 57*ef3a692cSMatthias Maennich "urls": [ 58*ef3a692cSMatthias Maennich "https://mirror.bazel.build/${path}", 59*ef3a692cSMatthias Maennich "https://${path}", 60*ef3a692cSMatthias Maennich ], 61*ef3a692cSMatthias Maennich 62*ef3a692cSMatthias MaennichCopy/paste this to mirror the file. 63*ef3a692cSMatthias Maennich 64*ef3a692cSMatthias Maennich gsutil cp /tmp/platforms-$version.tar.gz "gs://bazel-mirror/${path}" 65*ef3a692cSMatthias Maennich gsutil setmeta -h "Cache-Control: public, max-age=31536000" "gs://bazel-mirror/${path}" 66*ef3a692cSMatthias Maennich 67*ef3a692cSMatthias MaennichINP 68