Skip to content

Commit 2723b44

Browse files
committed
Add CI workflow to republish GH artifacts
1 parent ad3f698 commit 2723b44

File tree

1 file changed

+137
-0
lines changed

1 file changed

+137
-0
lines changed
Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
1+
name: Republish GH release
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
version:
7+
required: true
8+
type: string
9+
10+
env:
11+
DOTTY_CI_RUN: true
12+
13+
# In this file, we set `--cpu-shares 4096` on every job. This might seem useless
14+
# since it means that every container has the same weight which should be
15+
# equivalent to doing nothing, but it turns out that OpenJDK computes
16+
# `Runtime.getRuntime.availableProcessors` by dividing the cpu-shares value if
17+
# it exists by 1024 (cf
18+
# http://mail.openjdk.java.net/pipermail/hotspot-dev/2019-January/036087.html),
19+
# so this means that we effectively run every job with 4 cores. This is much
20+
# nicer than setting `--cpus 4` because the latter enforces CPU quotas and ends
21+
# up slowing our jobs more than needed. It's equivalent to running the JVM with
22+
# `-XX:ActiveProcessorCount=4`, but since our tests can spawn new JVM in many
23+
# places, it would be very hard to ensure that this option is always passed to
24+
# `java` (we could use the `_JAVA_OPTIONS` environment variable, but this prints
25+
# text on stderr and so can break tests which check the output of a program).
26+
27+
jobs:
28+
publish_release:
29+
permissions:
30+
contents: write # for GH CLI to create a release
31+
runs-on: [self-hosted, Linux]
32+
container:
33+
image: lampepfl/dotty:2024-10-18
34+
options: --cpu-shares 4096
35+
volumes:
36+
- ${{ github.workspace }}/../../cache/sbt:/root/.sbt
37+
- ${{ github.workspace }}/../../cache/ivy:/root/.ivy2/cache
38+
- ${{ github.workspace }}/../../cache/general:/root/.cache
39+
40+
env:
41+
RELEASEBUILD: yes
42+
43+
steps:
44+
######################################################################################
45+
## WARNING: DO NOT CHANGE THE JAVA VERSION HERE. SCALA IS DISTRIBUTED USING JAVA 8. ##
46+
######################################################################################
47+
- name: Set JDK 8 as default
48+
run: echo "/usr/lib/jvm/java-8-openjdk-amd64/bin" >> $GITHUB_PATH
49+
- name: Reset existing repo
50+
run: |
51+
git config --global --add safe.directory /__w/scala3/scala3
52+
git -c "http.https://github.com/.extraheader=" fetch --recurse-submodules=no "https://github.com/scala/scala3" && git reset --hard FETCH_HEAD || true
53+
54+
- name: Checkout cleanup script
55+
uses: actions/checkout@v4
56+
57+
- name: Cleanup
58+
run: .github/workflows/cleanup.sh
59+
60+
- name: Git Checkout
61+
uses: actions/checkout@v4
62+
63+
- name: Add SBT proxy repositories
64+
run: cp -vf .github/workflows/repositories /root/.sbt/ ; true
65+
66+
- name: Check compiler version
67+
shell: bash
68+
run : |
69+
version=$(./project/scripts/sbt "print scala3-compiler-bootstrapped/version" | tail -n1)
70+
echo "This build version: ${version}"
71+
if [ "${version}" != "${{ inputs.version }}" ]; then
72+
echo "Compiler version for this build '${version}', does not match tag: ${{ inputs.version }}"
73+
exit 1
74+
fi
75+
76+
77+
- name: Prepare the SDKs
78+
shell: bash
79+
run : |
80+
git config --global --add safe.directory /__w/scala3/scala3
81+
prepareSDK() {
82+
distroSuffix="$1"
83+
sbtProject="$2"
84+
distDir="$3"
85+
86+
# Build binaries
87+
./project/scripts/sbt "all ${sbtProject}/Universal/packageBin ${sbtProject}/Universal/packageZipTarball"
88+
89+
outputPath="${distDir}/target/universal/stage"
90+
artifactName="scala3-${{ inputs.version }}${distroSuffix}"
91+
zipArchive="${artifactName}.zip"
92+
tarGzArchive="${artifactName}.tar.gz"
93+
94+
# Caluclate SHA for each of archive files
95+
for file in "${zipArchive}" "${tarGzArchive}"; do
96+
mv $outputPath/$file $file
97+
sha256sum "${file}" > "${file}.sha256"
98+
done
99+
}
100+
prepareSDK "" "dist" "./dist/"
101+
prepareSDK "-aarch64-pc-linux" "dist-linux-aarch64" "./dist/linux-aarch64/"
102+
prepareSDK "-x86_64-pc-linux" "dist-linux-x86_64" "./dist/linux-x86_64/"
103+
prepareSDK "-aarch64-apple-darwin" "dist-mac-aarch64" "./dist/mac-aarch64/"
104+
prepareSDK "-x86_64-apple-darwin" "dist-mac-x86_64" "./dist/mac-x86_64/"
105+
prepareSDK "-x86_64-pc-win32" "dist-win-x86_64" "./dist/win-x86_64/"
106+
107+
# - name: Download MSI package
108+
# uses: actions/download-artifact@v4
109+
# with:
110+
# name: scala.msi
111+
# path: .
112+
# - name: Prepare MSI package
113+
# shell: bash
114+
# run: |
115+
# msiInstaller="scala3-${{ inputs.version }}.msi"
116+
# mv scala.msi "${msiInstaller}"
117+
# sha256sum "${msiInstaller}" > "${msiInstaller}.sha256"
118+
119+
- name: Install GH CLI
120+
uses: dev-hanz-ops/[email protected]
121+
with:
122+
gh-cli-version: 2.59.0
123+
124+
# Create the GitHub release
125+
- name: Create GitHub Release
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
128+
shell: bash
129+
run: |
130+
git config --global --add safe.directory /__w/scala3/scala3
131+
gh release upload ${{ inputs.version }} \
132+
--clobber \
133+
scala3-${{ inputs.version }}*.zip \
134+
scala3-${{ inputs.version }}*.tar.gz \
135+
scala3-${{ inputs.version }}*.sha256
136+
137+
# scala3-${{ inputs.version }}.msi

0 commit comments

Comments
 (0)