Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
3b042a8
Publish to builds.hex.pm after publish a release
wingyplus Sep 18, 2024
7e58333
Temporary close builds.hex.pm
wingyplus Sep 18, 2024
2f0c12b
Fix artifacts not download
wingyplus Sep 18, 2024
9ee4ded
Fix shell syntax error
wingyplus Sep 18, 2024
28e7a16
Fix utils.sh syntax error
wingyplus Sep 18, 2024
28bf685
Try echo
wingyplus Sep 18, 2024
9a9436c
Fix shell syntax error again
wingyplus Sep 18, 2024
7ddf0c8
Inline zips
wingyplus Sep 18, 2024
6ae7c25
Fix unterminated quote in sed
wingyplus Sep 18, 2024
e9aa682
Make upload docs works
wingyplus Sep 20, 2024
1f80bf3
Publish builds.txt
wingyplus Sep 25, 2024
621be39
Fix syntax error
wingyplus Sep 25, 2024
72a13ae
Fix error
wingyplus Sep 25, 2024
06e8e2e
Debugging CI
wingyplus Sep 25, 2024
3d765af
Fix the error
wingyplus Sep 25, 2024
2e82eb5
Correct the sed replace string
wingyplus Sep 25, 2024
6ff851b
Fix string comparison
wingyplus Sep 25, 2024
8791962
Fix actionlint
wingyplus Sep 25, 2024
7f1aaab
Fix aws cli error
wingyplus Sep 25, 2024
e14cfa1
Re-enable Fastly
wingyplus Sep 25, 2024
293ef97
Drop builds.hex.pm.yml
wingyplus Sep 25, 2024
7f26c5f
Update .github/workflows/release.yml
wingyplus Sep 25, 2024
9c8db54
Move purge keys to the last step
wingyplus Sep 26, 2024
20b32ad
Investigate bug
wingyplus Sep 26, 2024
38f8861
Investigate bugs #2
wingyplus Sep 26, 2024
019ca44
Investigate bugs #3
wingyplus Sep 26, 2024
aa308b3
Flush cache when run on elixir-lang/elixir repository
wingyplus Sep 26, 2024
40f0dda
Drop utils.sh
wingyplus Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 0 additions & 144 deletions .github/workflows/builds.hex.pm.yml

This file was deleted.

120 changes: 119 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:
name: Docs
path: Docs.zip*

upload:
upload-release:
needs: build
runs-on: windows-2022

Expand Down Expand Up @@ -149,3 +149,121 @@ jobs:
elixir-otp-*.exe.sha{1,256}sum \
Docs.zip \
Docs.zip.sha{1,256}sum

upload-builds-hex-pm:
needs: build
runs-on: ubuntu-22.04
concurrency: builds-hex-pm
env:
AWS_ACCESS_KEY_ID: ${{ secrets.HEX_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.HEX_AWS_SECRET_ACCESS_KEY }}
AWS_REGION: ${{ secrets.HEX_AWS_REGION }}
AWS_S3_BUCKET: ${{ secrets.HEX_AWS_S3_BUCKET }}
FASTLY_REPO_SERVICE_ID: ${{ secrets.HEX_FASTLY_REPO_SERVICE_ID }}
FASTLY_BUILDS_SERVICE_ID: ${{ secrets.HEX_FASTLY_BUILDS_SERVICE_ID }}
FASTLY_KEY: ${{ secrets.HEX_FASTLY_KEY }}
OTP_GENERIC_VERSION: '25'
steps:
- uses: actions/download-artifact@v4

- name: Init purge keys file
run: |
touch purge_keys.txt

- name: Upload Precompiled to S3
run: |
ref_name=${{ github.ref_name }}

mv elixir-otp-*/* .
for zip in $(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///'); do
dest=${zip/elixir/${ref_name}}
surrogate_key=${dest/.zip$/}

aws s3 cp "${zip}" "s3://${AWS_S3_BUCKET}/builds/elixir/${dest}" \
--cache-control "public,max-age=3600" \
--metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}"
echo "builds/elixir/${surrogate_key}" >> purge_keys.txt

if [ "$zip" == "elixir-otp-${OTP_GENERIC_VERSION}.zip" ]; then
aws s3 cp "${zip}" "s3://${AWS_S3_BUCKET}/builds/elixir/${ref_name}.zip" \
--cache-control "public,max-age=3600" \
--metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${ref_name}\",\"surrogate-control\":\"public,max-age=604800\"}"
echo builds/elixir/${ref_name} >> purge_keys.txt
fi
done

- name: Upload Docs to S3
working-directory: Docs
run: |
version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g')

unzip Docs.zip

for f in doc/*; do
if [ -d "$f" ]; then
app=$(echo "$f" | sed s/"doc\/"//)
tarball="${app}-${version}.tar.gz"
surrogate_key="docs/${app}-${version}"

tar -czf "${tarball}" -C "doc/${app}" .
aws s3 cp "${tarball}" "s3://${AWS_S3_BUCKET}/docs/${tarball}" \
--cache-control "public,max-age=3600" \
--metadata "{\"surrogate-key\":\"${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}"
echo "${surrogate_key}" >> ../purge_keys.txt
fi
done

- name: Update builds txt
run: |
date="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
ref_name=${{ github.ref_name }}

aws s3 cp "s3://${AWS_S3_BUCKET}/builds/elixir/builds.txt" builds.txt || true
touch builds.txt

for sha256_file in $(find . -name 'elixir-otp-*.zip.sha256sum' | sed 's/^\.\///'); do
otp_version=$(echo "${sha256_file}" | sed -r 's/^elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/')
build_sha256=$(cut -d ' ' -f 1 "${sha256_file}")

sed -i "/^${ref_name}-${otp_version} /d" builds.txt
echo -e "${ref_name}-${otp_version} ${{ github.sha }} ${date} ${build_sha256} \n$(cat builds.txt)" > builds.txt

if [ "${otp_version}" == "otp-${OTP_GENERIC_VERSION}" ]; then
sed -i "/^${ref_name} /d" builds.txt
echo -e "${ref_name} ${{ github.sha }} ${date} ${build_sha256} \n$(cat builds.txt)" > builds.txt
fi
done

sort -u -k1,1 -o builds.txt builds.txt
aws s3 cp builds.txt "s3://${AWS_S3_BUCKET}/builds/elixir/builds.txt" \
--cache-control "public,max-age=3600" \
--metadata '{"surrogate-key":"builds builds/elixir builds/elixir/txt","surrogate-control":"public,max-age=604800"}'

echo 'builds/elixir/txt' >> purge_keys.txt

- name: Flush cache
if: github.repository == 'elixir-lang/elixir'
run: |
function purge_key() {
curl \
-X POST \
-H "Fastly-Key: ${FASTLY_KEY}" \
-H "Accept: application/json" \
-H "Content-Length: 0" \
"https://api.fastly.com/service/$1/purge/$2"
}

function purge() {
purge_key ${FASTLY_REPO_SERVICE_ID} $1
purge_key ${FASTLY_BUILDS_SERVICE_ID} $1
sleep 2
purge_key ${FASTLY_REPO_SERVICE_ID} $1
purge_key ${FASTLY_BUILDS_SERVICE_ID} $1
sleep 2
purge_key ${FASTLY_REPO_SERVICE_ID} $1
purge_key ${FASTLY_BUILDS_SERVICE_ID} $1
}

for key in $(cat purge_keys.txt); do
purge "${key}"
done
Loading