Skip to content

Commit 34f1c54

Browse files
Fix and future-proof the CI release scripts (#21810)
- Forward-ports changes to `publish_release` CI job from `release-3.6.1` branch. * Fix building SDK archives, don't use `build-sdk-packages` job that produced artifacts in SNAPSHOT version * Fix typos introduced in template (forward port from `release-3.6.0`) - Detect and check version used to publish artifacts: * For release builds ensure that `version` is always matching tag used to trigger CI job * For nightly builds ensure that `version` is following the expected pattern
1 parent 9d78307 commit 34f1c54

File tree

1 file changed

+47
-42
lines changed

1 file changed

+47
-42
lines changed

Diff for: .github/workflows/ci.yaml

+47-42
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,13 @@ jobs:
663663
echo "This build version: $ver"
664664
echo "THISBUILD_VERSION=$ver" >> $GITHUB_ENV
665665
666+
- name: Check is version matching pattern
667+
run: |
668+
if ! grep -Eo "3\.[0-9]+\.[0-9]+-RC[0-9]+-bin-[0-9]{8}-[a-zA-Z0-9]{7}-NIGHTLY" <<< "${{ env.THISBUILD_VERSION }}"; then
669+
echo "Version used by compiler to publish nightly release does not match expected pattern"
670+
exit 1
671+
fi
672+
666673
- name: Check whether not yet published
667674
id: not_yet_published
668675
continue-on-error: true
@@ -766,49 +773,47 @@ jobs:
766773
- name: Extract the release tag
767774
run : echo "RELEASE_TAG=${GITHUB_REF#*refs/tags/}" >> $GITHUB_ENV
768775

776+
- name: Check compiler version
777+
shell: bash
778+
run : |
779+
version=$(./project/scripts/sbt "print scala3-compiler-bootstrapped/version" | tail -n1)
780+
echo "This build version: ${version}"
781+
if [ "${version}" != "${{ env.RELEASE_TAG }}" ]; then
782+
echo "Compiler version for this build '${version}', does not match tag: ${{ env.RELEASE_TAG }}"
783+
exit 1
784+
fi
785+
769786
- name: Prepare the SDKs
787+
shell: bash
770788
run : |
771-
function prepareSDK() {
789+
prepareSDK() {
772790
distroSuffix="$1"
773-
artifactId="$2"
791+
sbtProject="$2"
792+
distDir="$3"
793+
794+
# Build binaries
795+
./project/scripts/sbt "${sbtProject}/Universal/stage"
796+
797+
outputPath="${distDir}/target/universal/stage"
774798
artifactName="scala3-${{ env.RELEASE_TAG }}${distroSuffix}"
799+
zipArchive="${artifactName}.zip"
800+
tarGzArchive="${artifactName}.tar.gz"
775801
776-
downloadedArchive="./artifact.zip"
777-
if [[ -f "${downloadedArchive}" ]]; then
778-
rm "${downloadedArchive}"
779-
fi
780-
781-
# Download previously prepared SDK bundle
782-
curl -L \
783-
-H "Authorization: token ${{secrets.GITHUB_TOKEN}}" \
784-
-H "Accept: application/vnd.github+json" \
785-
-o "${downloadedArchive}" \
786-
--retry 5 --retry-delay 10 --retry-connrefused \
787-
--max-time 600 --connect-timeout 60 \
788-
https://api.github.com/repos/scala/scala3/actions/artifacts/${artifactId}/zip
789-
790-
# Repackage content of .zip to .tar.gz and prepare digest
791-
tmpDir="./archive-tmp-dir"
792-
if [[ -d "${tmpDir}" ]]; then
793-
rm -r "${tmpDir}"
794-
fi
795-
mkdir "${tmpDir}"
796-
unzip "${downloadedArchive}" -d "${tmpDir}"
797-
798-
mv "${downloadedArchive}" "./${artifactName}.zip"
799-
tar -czf "${artifactName}.tar.gz" -C "${tmpDir}" .
802+
cwd=$(pwd)
803+
(cd $outputPath && zip -r ${zipArchive} . && mv ${zipArchive} "${cwd}/")
804+
tar -czf ${tarGzArchive} -C "$outputPath" .
800805
801806
# Caluclate SHA for each of archive files
802-
for file in "${artifactName}.zip" "${artifactName}.tar.gz"; do
807+
for file in "${zipArchive}" "${tarGzArchive}"; do
803808
sha256sum "${file}" > "${file}.sha256"
804809
done
805810
}
806-
prepareSDK "" ${{needs.build-sdk-package.outputs.universal-id}}
807-
prepareSDK "-aarch64-pc-linux" ${{needs.build-sdk-package.outputs.linux-aarch64-id}}
808-
prepareSDK "-x86_64-pc-linux" ${{needs.build-sdk-package.outputs.linux-x86_64-id}}
809-
prepareSDK "-aarch64-apple-darwin" ${{needs.build-sdk-package.outputs.mac-aarch64-id}}
810-
prepareSDK "-x86_64-apple-darwin" ${{needs.build-sdk-package.outputs.mac-x86_64-id}}
811-
prepareSDK "-x86_64-pc-win32" ${{needs.build-sdk-package.outputs.win-x86_64-id}}
811+
prepareSDK "" "dist" "./dist/"
812+
prepareSDK "-aarch64-pc-linux" "dist-linux-aarch64" "./dist/linux-aarch64/"
813+
prepareSDK "-x86_64-pc-linux" "dist-linux-x86_64" "./dist/linux-x86_64/"
814+
prepareSDK "-aarch64-apple-darwin" "dist-mac-aarch64" "./dist/mac-aarch64/"
815+
prepareSDK "-x86_64-apple-darwin" "dist-mac-x86_64" "./dist/mac-x86_64/"
816+
prepareSDK "-x86_64-pc-win32" "dist-win-x86_64" "./dist/win-x86_64/"
812817
813818
# Create the GitHub release
814819
- name: Create GitHub Release
@@ -850,7 +855,7 @@ jobs:
850855
# template("Linux x86-64", "-x86_64-pc-linux"),
851856
# template("Linux aarch64", "-aarch64-pc-linux"),
852857
# template("Mac x86-64", "-x86_64-apple-darwin"),
853-
# template("Mac aarch64", "-aarcb64-apple-darwin"),
858+
# template("Mac aarch64", "-aarch64-apple-darwin"),
854859
# template("Windows x86_64", "-x86_64-pc-win32")
855860
# ).foreach(println)
856861
# Universal
@@ -1016,35 +1021,35 @@ jobs:
10161021
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10171022
with:
10181023
upload_url: ${{ steps.create_gh_release.outputs.upload_url }}
1019-
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.zip
1020-
asset_name: scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.zip
1024+
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip
1025+
asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip
10211026
asset_content_type: application/zip
10221027
- name: Upload zip archive SHA to GitHub Release (Mac aarch64)
10231028
uses: actions/upload-release-asset@v1
10241029
env:
10251030
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10261031
with:
10271032
upload_url: ${{ steps.create_gh_release.outputs.upload_url }}
1028-
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.zip.sha256
1029-
asset_name: scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.zip.sha256
1033+
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip.sha256
1034+
asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.zip.sha256
10301035
asset_content_type: text/plain
10311036
- name: Upload tar.gz archive to GitHub Release (Mac aarch64)
10321037
uses: actions/upload-release-asset@v1
10331038
env:
10341039
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10351040
with:
10361041
upload_url: ${{ steps.create_gh_release.outputs.upload_url }}
1037-
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.tar.gz
1038-
asset_name: scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.tar.gz
1042+
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz
1043+
asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz
10391044
asset_content_type: application/gzip
10401045
- name: Upload tar.gz archive SHA to GitHub Release (Mac aarch64)
10411046
uses: actions/upload-release-asset@v1
10421047
env:
10431048
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10441049
with:
10451050
upload_url: ${{ steps.create_gh_release.outputs.upload_url }}
1046-
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.tar.gz.sha256
1047-
asset_name: scala3-${{ env.RELEASE_TAG }}-aarcb64-apple-darwin.tar.gz.sha256
1051+
asset_path: ./scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz.sha256
1052+
asset_name: scala3-${{ env.RELEASE_TAG }}-aarch64-apple-darwin.tar.gz.sha256
10481053
asset_content_type: text/plain
10491054

10501055

0 commit comments

Comments
 (0)