diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 91add81f44ae..422da26aa465 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -600,6 +600,44 @@ jobs: external_repository: lampepfl/dotty-website publish_branch: gh-pages + nightly_unmanaged_community_build: + # Self-hosted runner is used only for getting current build version + runs-on: [self-hosted, Linux] + container: + image: lampepfl/dotty:2021-03-22 + options: --cpu-shares 4096 + volumes: + - ${{ github.workspace }}/../../cache/sbt:/root/.sbt + - ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache + - ${{ github.workspace }}/../../cache/general:/root/.cache + needs: [publish_nightly] + if: "(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && github.repository == 'lampepfl/dotty'" + env: + NIGHTLYBUILD: yes + steps: + - name: Reset existing repo + run: git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/lampepfl/dotty" && git reset --hard FETCH_HEAD || true + + - name: Checkout cleanup script + uses: actions/checkout@v2 + + - name: Cleanup + run: .github/workflows/cleanup.sh + + - name: Git Checkout + uses: actions/checkout@v2 + + - name: Add SBT proxy repositories + run: cp -vf .github/workflows/repositories /root/.sbt/ ; true + + - name: Get version string for this build + run: | + ver=$(./project/scripts/sbt "print scala3-compiler-bootstrapped/version" | tail -n1) + echo "This build version: $ver" + echo "THISBUILD_VERSION=$ver" >> $GITHUB_ENV + # Steps above are copy-pasted from publish_nightly, needed only to resolve THISBUILD_VERSION + - name: Trigger unmanaged community build + run: .github/workflows/scripts/triggerUnmanagedCommunityBuild.sh "${{ secrets.BUILD_TOKEN }}" "$THISBUILD_VERSION" publish_release: runs-on: [self-hosted, Linux] diff --git a/.github/workflows/scripts/triggerUnmanagedCommunityBuild.sh b/.github/workflows/scripts/triggerUnmanagedCommunityBuild.sh new file mode 100755 index 000000000000..694428e29bb5 --- /dev/null +++ b/.github/workflows/scripts/triggerUnmanagedCommunityBuild.sh @@ -0,0 +1,37 @@ +#!/usr/bin/env bash + +# This is script for triggering unamanged community build upon releasing nightly version. +# Script sends request to CB Jenkins instance to start the build for given released Scala version +# Prints url of created job to stdout +# +# Requirement: +# - the latest (nightly) version of scala should be published + +set -u + +if [ $# -ne 2 ]; then + echo "Wrong number of script arguments, expected , got $#: $@" + exit 1 +fi + +CB_ENDPOINT=https://scala3.westeurope.cloudapp.azure.com +CB_BUILD_TOKEN="$1" +SCALA_VERSION="$2" + +startRunResponse=$(curl "${CB_ENDPOINT}/job/runBuild/buildWithParameters?token=${CB_BUILD_TOKEN}&publishedScalaVersion=${SCALA_VERSION}" -v 2>&1) +echo "${startRunResponse}" +queueItem=$(echo "${startRunResponse}" | grep -oP "< Location: \K[\w\d:/.//]+") +# Wait until Jenkins does acknowledge the build (max 1 min ) +for i in {1..12}; do + buildUrl=$(curl -s "${queueItem}/api/json?tree=executable[url]" | jq .executable.url) + if [[ "null" == "${buildUrl}" ]]; then + echo "Waiting for build start..." + sleep 5 + else + echo "Created build url: ${buildUrl}" + exit 0 + fi +done + +# Set error if failed to resolve build url +exit 1