From 3b042a8c705304b3a89d5b2b334d4fc9494882f5 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 01:41:08 +0700 Subject: [PATCH 01/28] Publish to builds.hex.pm after publish a release Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 111 +++++++++++++++++++++++++++++++++- 1 file changed, 110 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 044224f5a0f..3378755167b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -100,7 +100,7 @@ jobs: name: Docs path: Docs.zip* - upload: + upload-release: needs: build runs-on: windows-2022 @@ -149,3 +149,112 @@ jobs: elixir-otp-*.exe.sha{1,256}sum \ Docs.zip \ Docs.zip.sha{1,256}sum + + # NOTE: for the idea: + # + # - Re-download artifact after built precompiled. + # - Publish docs. + # - Publish precompiled. + # - Publish precompiled generic version (if any). + # - Update builds.txt. + 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/checkout@v4 + with: + fetch-depth: 1 + + - run: | + mv elixir-otp-*/* . + mv Docs/* . + shell: bash + + - name: Utils.sh + run: | + cat << 'EOF' > utils.sh + 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 + } + EOF + # - name: Upload Docs to S3 + # run: | + # source utils.sh + # version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g') + # 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://${{ env.AWS_S3_BUCKET }}/docs/${tarball}" \ + # --cache-control "public,max-age=3600" \ + # --metadata "{\"surrogate-key\":\"${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}" + # purge "${surrogate_key}" + # fi + # done + - name: Upload Precompiled to S3 + run: | + source utils.sh + zips=$(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///') + + for zip in zips + do + dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}') + surrogate_key=$(echo $dest | sed 's/\.zip$//') + + aws s3 cp "${zip}" "s3://${{ env.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\"}" + + if [ $zip == "elixir-otp-${OTP_GENERIC_VERSION}.zip" ]; then + aws s3 cp "${zip}" "s3://${AWS_S3_BUCKET}/builds/elixir/${{ github.ref_name }}.zip" \ + --cache-control "public,max-age=3600" \ + --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${{ github.ref_name }}\",\"surrogate-control\":\"public,max-age=604800\"}" + purge builds/elixir/${{ github.ref_name }} + fi + done + + # - name: Update builds txt + # run: | + # source utils.sh + # date=$(date -u '+%Y-%m-%dT%H:%M:%SZ') + # build_sha256=$(sha256sum elixir-otp-${{ matrix.otp }}.zip | cut -d ' ' -f 1) + # ref_name=${{ github.ref_name }} + # aws s3 cp s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/builds.txt builds.txt || true + # touch builds.txt + # sed -i "/^${ref_name}-otp-${{ matrix.otp }} /d" builds.txt + # echo -e "${ref_name}-otp-${{ matrix.otp }} ${{ github.sha }} ${date} ${build_sha256} \n$(cat builds.txt)" > builds.txt + # if [ "${{matrix.upload_generic_version}}" == "upload_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 + # sort -u -k1,1 -o builds.txt builds.txt + # aws s3 cp builds.txt s3://${{ env.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"}' + # purge builds/elixir/txt + From 7e58333086da33dc6e7d7a546116e140cf44a9e4 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 01:42:18 +0700 Subject: [PATCH 02/28] Temporary close builds.hex.pm Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/builds.hex.pm.yml | 251 ++++++++++++++-------------- 1 file changed, 128 insertions(+), 123 deletions(-) diff --git a/.github/workflows/builds.hex.pm.yml b/.github/workflows/builds.hex.pm.yml index 64ca07eaa52..af8dc8ed6dd 100644 --- a/.github/workflows/builds.hex.pm.yml +++ b/.github/workflows/builds.hex.pm.yml @@ -17,128 +17,133 @@ concurrency: builds_txt jobs: release_pre_built: - permissions: - id-token: write - attestations: write - strategy: - fail-fast: true - max-parallel: 1 - matrix: - include: - - otp: 25 - otp_version: "25.3" - upload_generic_version: upload_generic_version - - otp: 26 - otp_version: "26.0" - - otp: 27 - otp_version: "27.0" - build_docs: build_docs - runs-on: ubuntu-22.04 + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 50 - - name: Get tags - run: git fetch --tags origin - - uses: ./.github/workflows/release_pre_built - with: - otp_version: ${{ matrix.otp_version }} - otp: ${{ matrix.otp }} - build_docs: ${{ matrix.build_docs }} - - uses: actions/attest-build-provenance@v1 - with: - subject-path: 'elixir-otp-${{ matrix.otp }}.*' - - uses: actions/attest-build-provenance@v1 - if: ${{ matrix.build_docs }} - with: - subject-path: 'Docs.*' - - name: Utils.sh + - name: Temporary close run: | - cat << 'EOF' > utils.sh - 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 - } - EOF - chmod +x utils.sh - - name: Upload Docs to S3 - if: ${{ matrix.build_docs }} - 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 }} - run: | - source utils.sh - version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g') - 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://${{ env.AWS_S3_BUCKET }}/docs/${tarball}" \ - --cache-control "public,max-age=3600" \ - --metadata "{\"surrogate-key\":\"${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}" - purge "${surrogate_key}" - fi - done - - name: Upload Precompiled to S3 - 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 }} - run: | - source utils.sh - aws s3 cp elixir-otp-${{ matrix.otp }}.zip "s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}}.zip" --cache-control "public,max-age=3600" --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}}\",\"surrogate-control\":\"public,max-age=604800\"}" - purge builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}} - if [ "${{matrix.upload_generic_version}}" == "upload_generic_version" ]; then - aws s3 cp elixir-otp-${{ matrix.otp }}.zip "s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/${{github.ref_name}}.zip" --cache-control "public,max-age=3600" --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${{github.ref_name}}\",\"surrogate-control\":\"public,max-age=604800\"}" - purge builds/elixir/${{github.ref_name}} - fi - - name: Update builds txt - 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 }} - run: | - source utils.sh - date=$(date -u '+%Y-%m-%dT%H:%M:%SZ') - build_sha256=$(sha256sum elixir-otp-${{ matrix.otp }}.zip | cut -d ' ' -f 1) - ref_name=${{ github.ref_name }} - aws s3 cp s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/builds.txt builds.txt || true - touch builds.txt - sed -i "/^${ref_name}-otp-${{ matrix.otp }} /d" builds.txt - echo -e "${ref_name}-otp-${{ matrix.otp }} ${{ github.sha }} ${date} ${build_sha256} \n$(cat builds.txt)" > builds.txt - if [ "${{matrix.upload_generic_version}}" == "upload_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 - sort -u -k1,1 -o builds.txt builds.txt - aws s3 cp builds.txt s3://${{ env.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"}' - purge builds/elixir/txt + exit 0 + # permissions: + # id-token: write + # attestations: write + # strategy: + # fail-fast: true + # max-parallel: 1 + # matrix: + # include: + # - otp: 25 + # otp_version: "25.3" + # upload_generic_version: upload_generic_version + # - otp: 26 + # otp_version: "26.0" + # - otp: 27 + # otp_version: "27.0" + # build_docs: build_docs + # runs-on: ubuntu-22.04 + # steps: + # - uses: actions/checkout@v4 + # with: + # fetch-depth: 50 + # - name: Get tags + # run: git fetch --tags origin + # - uses: ./.github/workflows/release_pre_built + # with: + # otp_version: ${{ matrix.otp_version }} + # otp: ${{ matrix.otp }} + # build_docs: ${{ matrix.build_docs }} + # - uses: actions/attest-build-provenance@v1 + # with: + # subject-path: 'elixir-otp-${{ matrix.otp }}.*' + # - uses: actions/attest-build-provenance@v1 + # if: ${{ matrix.build_docs }} + # with: + # subject-path: 'Docs.*' + # - name: Utils.sh + # run: | + # cat << 'EOF' > utils.sh + # 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 + # } + # EOF + # chmod +x utils.sh + # - name: Upload Docs to S3 + # if: ${{ matrix.build_docs }} + # 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 }} + # run: | + # source utils.sh + # version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g') + # 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://${{ env.AWS_S3_BUCKET }}/docs/${tarball}" \ + # --cache-control "public,max-age=3600" \ + # --metadata "{\"surrogate-key\":\"${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}" + # purge "${surrogate_key}" + # fi + # done + # - name: Upload Precompiled to S3 + # 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 }} + # run: | + # source utils.sh + # aws s3 cp elixir-otp-${{ matrix.otp }}.zip "s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}}.zip" --cache-control "public,max-age=3600" --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}}\",\"surrogate-control\":\"public,max-age=604800\"}" + # purge builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}} + # if [ "${{matrix.upload_generic_version}}" == "upload_generic_version" ]; then + # aws s3 cp elixir-otp-${{ matrix.otp }}.zip "s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/${{github.ref_name}}.zip" --cache-control "public,max-age=3600" --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${{github.ref_name}}\",\"surrogate-control\":\"public,max-age=604800\"}" + # purge builds/elixir/${{github.ref_name}} + # fi + # - name: Update builds txt + # 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 }} + # run: | + # source utils.sh + # date=$(date -u '+%Y-%m-%dT%H:%M:%SZ') + # build_sha256=$(sha256sum elixir-otp-${{ matrix.otp }}.zip | cut -d ' ' -f 1) + # ref_name=${{ github.ref_name }} + # aws s3 cp s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/builds.txt builds.txt || true + # touch builds.txt + # sed -i "/^${ref_name}-otp-${{ matrix.otp }} /d" builds.txt + # echo -e "${ref_name}-otp-${{ matrix.otp }} ${{ github.sha }} ${date} ${build_sha256} \n$(cat builds.txt)" > builds.txt + # if [ "${{matrix.upload_generic_version}}" == "upload_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 + # sort -u -k1,1 -o builds.txt builds.txt + # aws s3 cp builds.txt s3://${{ env.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"}' + # purge builds/elixir/txt From 2f0c12b6f2ca20bf7d36329ed0bd8a28b732c2fb Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 01:46:25 +0700 Subject: [PATCH 03/28] Fix artifacts not download Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3378755167b..540771c2cc3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -171,15 +171,13 @@ jobs: FASTLY_KEY: ${{ secrets.HEX_FASTLY_KEY }} OTP_GENERIC_VERSION: '25' steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 1 + - uses: actions/download-artifact@v4 - run: | mv elixir-otp-*/* . mv Docs/* . shell: bash - + - name: Utils.sh run: | cat << 'EOF' > utils.sh From 9ee4ded69bf2fcfce89a8c0249420a9e40366848 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 01:50:15 +0700 Subject: [PATCH 04/28] Fix shell syntax error Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 540771c2cc3..57e978f22ab 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -221,7 +221,7 @@ jobs: source utils.sh zips=$(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///') - for zip in zips + for zip in "${zips}" do dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}') surrogate_key=$(echo $dest | sed 's/\.zip$//') From 28e7a162c5eff171d4ae8950672dbe80134c6f4e Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 01:54:16 +0700 Subject: [PATCH 05/28] Fix utils.sh syntax error Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57e978f22ab..bfa596bf72b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -188,6 +188,7 @@ jobs: # -H "Accept: application/json" \ # -H "Content-Length: 0" \ # "https://api.fastly.com/service/$1/purge/$2" + echo 'Temporary close' } function purge() { purge_key ${FASTLY_REPO_SERVICE_ID} $1 From 28bf685d9e1aa2d0ecc622bc863c06763345d592 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 01:58:39 +0700 Subject: [PATCH 06/28] Try echo Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bfa596bf72b..0ef204378c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -224,6 +224,7 @@ jobs: for zip in "${zips}" do + echo $zip dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}') surrogate_key=$(echo $dest | sed 's/\.zip$//') From 9a9436c6ec51f83cf68cbeaab6d2212f68747630 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 02:06:39 +0700 Subject: [PATCH 07/28] Fix shell syntax error again Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0ef204378c2..8664f4a92a7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -222,7 +222,7 @@ jobs: source utils.sh zips=$(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///') - for zip in "${zips}" + for zip in zips do echo $zip dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}') From 7ddf0c8a18bc2428994c88f97c11db636e6e459c Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 02:12:21 +0700 Subject: [PATCH 08/28] Inline zips Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8664f4a92a7..1f95ed6e318 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -220,15 +220,14 @@ jobs: - name: Upload Precompiled to S3 run: | source utils.sh - zips=$(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///') - for zip in zips + for zip in $(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///') do echo $zip dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}') surrogate_key=$(echo $dest | sed 's/\.zip$//') - aws s3 cp "${zip}" "s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/${dest}" \ + 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\"}" From 6ae7c25aefdb6e8943f6eab383c0bf87ad8637f6 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 19 Sep 2024 02:20:35 +0700 Subject: [PATCH 09/28] Fix unterminated quote in sed Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1f95ed6e318..bb1a1cf357f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -224,7 +224,7 @@ jobs: for zip in $(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///') do echo $zip - dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}') + dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}/') surrogate_key=$(echo $dest | sed 's/\.zip$//') aws s3 cp "${zip}" "s3://${AWS_S3_BUCKET}/builds/elixir/${dest}" \ From e9aa682fdd952ef0cc7cf7deac108841d4e7b7da Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Fri, 20 Sep 2024 23:48:40 +0700 Subject: [PATCH 10/28] Make upload docs works Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 45 +++++++++++++++++------------------ 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bb1a1cf357f..cf5d842bcff 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -173,11 +173,6 @@ jobs: steps: - uses: actions/download-artifact@v4 - - run: | - mv elixir-otp-*/* . - mv Docs/* . - shell: bash - - name: Utils.sh run: | cat << 'EOF' > utils.sh @@ -201,28 +196,12 @@ jobs: purge_key ${FASTLY_BUILDS_SERVICE_ID} $1 } EOF - # - name: Upload Docs to S3 - # run: | - # source utils.sh - # version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g') - # 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://${{ env.AWS_S3_BUCKET }}/docs/${tarball}" \ - # --cache-control "public,max-age=3600" \ - # --metadata "{\"surrogate-key\":\"${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}" - # purge "${surrogate_key}" - # fi - # done - name: Upload Precompiled to S3 run: | source utils.sh - for zip in $(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///') - do + mv elixir-otp-*/* . + for zip in $(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///'); do echo $zip dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}/') surrogate_key=$(echo $dest | sed 's/\.zip$//') @@ -238,6 +217,26 @@ jobs: purge builds/elixir/${{ github.ref_name }} fi done + - name: Upload Docs to S3 + working-directory: Docs + run: | + source ../utils.sh + 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\"}" + purge "${surrogate_key}" + fi + done # - name: Update builds txt # run: | From 1f80bf3d29c24a66b9387a955e0e310e61134df5 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Wed, 25 Sep 2024 23:36:30 +0700 Subject: [PATCH 11/28] Publish builds.txt Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 59 ++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cf5d842bcff..d5f0c22576c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -150,14 +150,7 @@ jobs: Docs.zip \ Docs.zip.sha{1,256}sum - # NOTE: for the idea: - # - # - Re-download artifact after built precompiled. - # - Publish docs. - # - Publish precompiled. - # - Publish precompiled generic version (if any). - # - Update builds.txt. - upload-builds-hex-pm: + upload-builds-hex-pm: needs: build runs-on: ubuntu-22.04 concurrency: builds-hex-pm @@ -208,7 +201,7 @@ jobs: 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\"}" + --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}" if [ $zip == "elixir-otp-${OTP_GENERIC_VERSION}.zip" ]; then aws s3 cp "${zip}" "s3://${AWS_S3_BUCKET}/builds/elixir/${{ github.ref_name }}.zip" \ @@ -237,22 +230,32 @@ jobs: purge "${surrogate_key}" fi done - - # - name: Update builds txt - # run: | - # source utils.sh - # date=$(date -u '+%Y-%m-%dT%H:%M:%SZ') - # build_sha256=$(sha256sum elixir-otp-${{ matrix.otp }}.zip | cut -d ' ' -f 1) - # ref_name=${{ github.ref_name }} - # aws s3 cp s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/builds.txt builds.txt || true - # touch builds.txt - # sed -i "/^${ref_name}-otp-${{ matrix.otp }} /d" builds.txt - # echo -e "${ref_name}-otp-${{ matrix.otp }} ${{ github.sha }} ${date} ${build_sha256} \n$(cat builds.txt)" > builds.txt - # if [ "${{matrix.upload_generic_version}}" == "upload_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 - # sort -u -k1,1 -o builds.txt builds.txt - # aws s3 cp builds.txt s3://${{ env.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"}' - # purge builds/elixir/txt - + + - name: Update builds txt + run: | + source utils.sh + sha256_files=$(find . -name elixir-otp-*.sha256sum) + 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 sha256_files; do + otp_version=$(echo ${sha256_file} | sed -r 's/elixir-otp-([[:digit:]]+)\.sha256sum/otp-\1/') + build_sha256=$(cat ${sha256_file} | cut -d ' ' -f 1) + + 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_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"}' + purge builds/elixir/txt From 621be3915cb67b7c4c17b5bd638e006ec82e7917 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Wed, 25 Sep 2024 23:42:03 +0700 Subject: [PATCH 12/28] Fix syntax error Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d5f0c22576c..d6f85362676 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -234,7 +234,7 @@ jobs: - name: Update builds txt run: | source utils.sh - sha256_files=$(find . -name elixir-otp-*.sha256sum) + sha256_files=$(find . -name 'elixir-otp-*.zip.sha256sum') date=$(date -u '+%Y-%m-%dT%H:%M:%SZ') ref_name=${{ github.ref_name }} @@ -242,7 +242,7 @@ jobs: touch builds.txt for sha256_file in sha256_files; do - otp_version=$(echo ${sha256_file} | sed -r 's/elixir-otp-([[:digit:]]+)\.sha256sum/otp-\1/') + otp_version=$(echo ${sha256_file} | sed -r 's/elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') build_sha256=$(cat ${sha256_file} | cut -d ' ' -f 1) sed -i "/^${ref_name}-${otp_version} /d" builds.txt From 72a13aee31411feba5ef9ebf3a7e019b1e0e40fb Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Wed, 25 Sep 2024 23:47:13 +0700 Subject: [PATCH 13/28] Fix error Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d6f85362676..7627c75cd0f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -234,14 +234,13 @@ jobs: - name: Update builds txt run: | source utils.sh - sha256_files=$(find . -name 'elixir-otp-*.zip.sha256sum') 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 sha256_files; do + for sha256_file in $(find . -name 'elixir-otp-*.zip.sha256sum'); do otp_version=$(echo ${sha256_file} | sed -r 's/elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') build_sha256=$(cat ${sha256_file} | cut -d ' ' -f 1) From 06e8e2e0137cc79de1b2847f298fd1f3867d0408 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Wed, 25 Sep 2024 23:51:35 +0700 Subject: [PATCH 14/28] Debugging CI Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7627c75cd0f..96d4a9980c2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -241,6 +241,7 @@ jobs: touch builds.txt for sha256_file in $(find . -name 'elixir-otp-*.zip.sha256sum'); do + echo ${sha256_file} otp_version=$(echo ${sha256_file} | sed -r 's/elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') build_sha256=$(cat ${sha256_file} | cut -d ' ' -f 1) From 3d765afc59538d203954d17fbe39e134d89bef66 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Wed, 25 Sep 2024 23:56:31 +0700 Subject: [PATCH 15/28] Fix the error Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 96d4a9980c2..a2888feaabc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -242,7 +242,7 @@ jobs: for sha256_file in $(find . -name 'elixir-otp-*.zip.sha256sum'); do echo ${sha256_file} - otp_version=$(echo ${sha256_file} | sed -r 's/elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') + otp_version=$(echo ${sha256_file} | sed -r 's/^\.\/elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') build_sha256=$(cat ${sha256_file} | cut -d ' ' -f 1) sed -i "/^${ref_name}-${otp_version} /d" builds.txt From 2e82eb53c02015f7965e67d32b892ac47e6d1eb8 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 00:08:33 +0700 Subject: [PATCH 16/28] Correct the sed replace string Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a2888feaabc..e09ec849e35 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -240,9 +240,9 @@ jobs: 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'); do + for sha256_file in $(find . -name 'elixir-otp-*.zip.sha256sum' | sed 's/^\.\///'); do echo ${sha256_file} - otp_version=$(echo ${sha256_file} | sed -r 's/^\.\/elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') + otp_version=$(echo ${sha256_file} | sed -r 's/^elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') build_sha256=$(cat ${sha256_file} | cut -d ' ' -f 1) sed -i "/^${ref_name}-${otp_version} /d" builds.txt From 6ff851ba19c7fa6d89d864d1c1ab71c71068a7f4 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 00:12:37 +0700 Subject: [PATCH 17/28] Fix string comparison Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e09ec849e35..57c4cb0e5ac 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -248,7 +248,7 @@ jobs: 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_GENERIC_VERSION}" ]; then + 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 From 8791962a1129d59998211bb16d0c94abcdd5adc4 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 00:40:56 +0700 Subject: [PATCH 18/28] Fix actionlint Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57c4cb0e5ac..8d7f4dc63e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -192,22 +192,22 @@ jobs: - name: Upload Precompiled to S3 run: | source utils.sh + ref_name=${{ github.ref_name }} mv elixir-otp-*/* . for zip in $(find . -type f -name 'elixir-otp-*.zip' | sed 's/^\.\///'); do - echo $zip - dest=$(echo $zip | sed 's/^elixir/${{ github.ref_name }}/') - surrogate_key=$(echo $dest | sed 's/\.zip$//') + 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\"}" - if [ $zip == "elixir-otp-${OTP_GENERIC_VERSION}.zip" ]; then - aws s3 cp "${zip}" "s3://${AWS_S3_BUCKET}/builds/elixir/${{ github.ref_name }}.zip" \ + 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/${{ github.ref_name }}\",\"surrogate-control\":\"public,max-age=604800\"}" - purge builds/elixir/${{ github.ref_name }} + --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${ref_name}\",\"surrogate-control\":\"public,max-age=604800\"}" + purge builds/elixir/${ref_name} fi done - name: Upload Docs to S3 @@ -220,7 +220,7 @@ jobs: for f in doc/*; do if [ -d "$f" ]; then - app=$(echo $f | sed s/"doc\/"//) + app=$(echo "$f" | sed s/"doc\/"//) tarball="${app}-${version}.tar.gz" surrogate_key="docs/${app}-${version}" tar -czf "${tarball}" -C "doc/${app}" . @@ -234,16 +234,15 @@ jobs: - name: Update builds txt run: | source utils.sh - date=$(date -u '+%Y-%m-%dT%H:%M:%SZ') + 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 + 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 - echo ${sha256_file} - otp_version=$(echo ${sha256_file} | sed -r 's/^elixir-otp-([[:digit:]]+)\.zip\.sha256sum/otp-\1/') - build_sha256=$(cat ${sha256_file} | cut -d ' ' -f 1) + 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 @@ -255,7 +254,7 @@ jobs: done sort -u -k1,1 -o builds.txt builds.txt - aws s3 cp builds.txt s3://${AWS_S3_BUCKET}/builds/elixir/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"}' purge builds/elixir/txt From 7f1aaabec30a4160e162e6a246055ad5217bff28 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 00:45:20 +0700 Subject: [PATCH 19/28] Fix aws cli error Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d7f4dc63e3..0aae1995109 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -237,7 +237,7 @@ jobs: 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 + 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 From e14cfa1843a4dc47d957887697ff1fdf982bc89c Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 00:59:07 +0700 Subject: [PATCH 20/28] Re-enable Fastly Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0aae1995109..696be446525 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -170,12 +170,12 @@ jobs: run: | cat << 'EOF' > utils.sh 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" + curl \ + -X POST \ + -H "Fastly-Key: ${FASTLY_KEY}" \ + -H "Accept: application/json" \ + -H "Content-Length: 0" \ + "https://api.fastly.com/service/$1/purge/$2" echo 'Temporary close' } function purge() { From 293ef9747a58c5c4f10c3d5ef832fe1dc50daafc Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 00:59:34 +0700 Subject: [PATCH 21/28] Drop builds.hex.pm.yml Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/builds.hex.pm.yml | 149 ---------------------------- 1 file changed, 149 deletions(-) delete mode 100644 .github/workflows/builds.hex.pm.yml diff --git a/.github/workflows/builds.hex.pm.yml b/.github/workflows/builds.hex.pm.yml deleted file mode 100644 index af8dc8ed6dd..00000000000 --- a/.github/workflows/builds.hex.pm.yml +++ /dev/null @@ -1,149 +0,0 @@ -name: builds.hex.pm - -on: - push: - branches: - - main - - v*.* - tags: - - v* - -env: - ELIXIR_OPTS: "--warnings-as-errors" - ERLC_OPTS: "warnings_as_errors" - LANG: C.UTF-8 - -concurrency: builds_txt - -jobs: - release_pre_built: - runs-on: ubuntu-latest - steps: - - name: Temporary close - run: | - exit 0 - # permissions: - # id-token: write - # attestations: write - # strategy: - # fail-fast: true - # max-parallel: 1 - # matrix: - # include: - # - otp: 25 - # otp_version: "25.3" - # upload_generic_version: upload_generic_version - # - otp: 26 - # otp_version: "26.0" - # - otp: 27 - # otp_version: "27.0" - # build_docs: build_docs - # runs-on: ubuntu-22.04 - # steps: - # - uses: actions/checkout@v4 - # with: - # fetch-depth: 50 - # - name: Get tags - # run: git fetch --tags origin - # - uses: ./.github/workflows/release_pre_built - # with: - # otp_version: ${{ matrix.otp_version }} - # otp: ${{ matrix.otp }} - # build_docs: ${{ matrix.build_docs }} - # - uses: actions/attest-build-provenance@v1 - # with: - # subject-path: 'elixir-otp-${{ matrix.otp }}.*' - # - uses: actions/attest-build-provenance@v1 - # if: ${{ matrix.build_docs }} - # with: - # subject-path: 'Docs.*' - # - name: Utils.sh - # run: | - # cat << 'EOF' > utils.sh - # 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 - # } - # EOF - # chmod +x utils.sh - # - name: Upload Docs to S3 - # if: ${{ matrix.build_docs }} - # 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 }} - # run: | - # source utils.sh - # version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g') - # 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://${{ env.AWS_S3_BUCKET }}/docs/${tarball}" \ - # --cache-control "public,max-age=3600" \ - # --metadata "{\"surrogate-key\":\"${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}" - # purge "${surrogate_key}" - # fi - # done - # - name: Upload Precompiled to S3 - # 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 }} - # run: | - # source utils.sh - # aws s3 cp elixir-otp-${{ matrix.otp }}.zip "s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}}.zip" --cache-control "public,max-age=3600" --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}}\",\"surrogate-control\":\"public,max-age=604800\"}" - # purge builds/elixir/${{github.ref_name}}-otp-${{matrix.otp}} - # if [ "${{matrix.upload_generic_version}}" == "upload_generic_version" ]; then - # aws s3 cp elixir-otp-${{ matrix.otp }}.zip "s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/${{github.ref_name}}.zip" --cache-control "public,max-age=3600" --metadata "{\"surrogate-key\":\"builds builds/elixir builds/elixir/${{github.ref_name}}\",\"surrogate-control\":\"public,max-age=604800\"}" - # purge builds/elixir/${{github.ref_name}} - # fi - # - name: Update builds txt - # 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 }} - # run: | - # source utils.sh - # date=$(date -u '+%Y-%m-%dT%H:%M:%SZ') - # build_sha256=$(sha256sum elixir-otp-${{ matrix.otp }}.zip | cut -d ' ' -f 1) - # ref_name=${{ github.ref_name }} - # aws s3 cp s3://${{ env.AWS_S3_BUCKET }}/builds/elixir/builds.txt builds.txt || true - # touch builds.txt - # sed -i "/^${ref_name}-otp-${{ matrix.otp }} /d" builds.txt - # echo -e "${ref_name}-otp-${{ matrix.otp }} ${{ github.sha }} ${date} ${build_sha256} \n$(cat builds.txt)" > builds.txt - # if [ "${{matrix.upload_generic_version}}" == "upload_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 - # sort -u -k1,1 -o builds.txt builds.txt - # aws s3 cp builds.txt s3://${{ env.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"}' - # purge builds/elixir/txt From 7f26c5fec20cde340fa245abc5becbc13eaf3958 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 01:03:57 +0700 Subject: [PATCH 22/28] Update .github/workflows/release.yml --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 696be446525..8049d1118c7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -176,7 +176,6 @@ jobs: -H "Accept: application/json" \ -H "Content-Length: 0" \ "https://api.fastly.com/service/$1/purge/$2" - echo 'Temporary close' } function purge() { purge_key ${FASTLY_REPO_SERVICE_ID} $1 From 9c8db54886cddf25cd76d4aa84fa7f6f59b2f2e0 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 22:48:17 +0700 Subject: [PATCH 23/28] Move purge keys to the last step Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 44 +++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8049d1118c7..af6861d77df 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -166,6 +166,10 @@ jobs: steps: - uses: actions/download-artifact@v4 + - name: Init purge keys file + run: | + touch purge_keys.txt + - name: Utils.sh run: | cat << 'EOF' > utils.sh @@ -188,6 +192,7 @@ jobs: purge_key ${FASTLY_BUILDS_SERVICE_ID} $1 } EOF + - name: Upload Precompiled to S3 run: | source utils.sh @@ -201,18 +206,19 @@ jobs: 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\"}" - purge builds/elixir/${ref_name} + echo builds/elixir/${ref_name} >> purge_keys.txt fi done + - name: Upload Docs to S3 working-directory: Docs run: | - source ../utils.sh version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g') unzip Docs.zip @@ -222,17 +228,17 @@ jobs: 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\"}" - purge "${surrogate_key}" + echo "${surrogate_key}" >> purge_keys.txt fi done - name: Update builds txt run: | - source utils.sh date="$(date -u '+%Y-%m-%dT%H:%M:%SZ')" ref_name=${{ github.ref_name }} @@ -256,4 +262,32 @@ jobs: 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"}' - purge builds/elixir/txt + + echo 'buils/elixir/txt' >> purge_keys.txt + + - name: Flush cache + run: | + function purge_key() { + echo "Purge key $2" + # 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 From 20b32ada79b3571c31dca5c0ab8eaf1d02d0e4e1 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 22:54:39 +0700 Subject: [PATCH 24/28] Investigate bug Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index af6861d77df..fd792866b7c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -234,6 +234,7 @@ jobs: --cache-control "public,max-age=3600" \ --metadata "{\"surrogate-key\":\"${surrogate_key}\",\"surrogate-control\":\"public,max-age=604800\"}" echo "${surrogate_key}" >> purge_keys.txt + echo "Purge key ${surrogate_key}" fi done From 38f8861aa8e1c0dc5bcaca612eb87d9f33f83018 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 22:58:25 +0700 Subject: [PATCH 25/28] Investigate bugs #2 Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fd792866b7c..64538d2e57b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -289,6 +289,8 @@ jobs: purge_key ${FASTLY_BUILDS_SERVICE_ID} $1 } + cat purge_keys.txt + for key in $(cat purge_keys.txt); do purge "${key}" done From 019ca44ae5e328d28eab26f093523d0ec9e38e17 Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 23:06:25 +0700 Subject: [PATCH 26/28] Investigate bugs #3 Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 64538d2e57b..191621faf7d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -233,8 +233,7 @@ jobs: 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 - echo "Purge key ${surrogate_key}" + echo "${surrogate_key}" >> ../purge_keys.txt fi done @@ -264,7 +263,7 @@ jobs: --cache-control "public,max-age=3600" \ --metadata '{"surrogate-key":"builds builds/elixir builds/elixir/txt","surrogate-control":"public,max-age=604800"}' - echo 'buils/elixir/txt' >> purge_keys.txt + echo 'builds/elixir/txt' >> purge_keys.txt - name: Flush cache run: | From aa308b30a712ad4d10ac3d1080554ce7f7776ddb Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 23:11:49 +0700 Subject: [PATCH 27/28] Flush cache when run on elixir-lang/elixir repository Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 191621faf7d..5ff26180ca5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -266,15 +266,15 @@ jobs: echo 'builds/elixir/txt' >> purge_keys.txt - name: Flush cache + if: github.repository == 'elixir-lang/elixir' run: | function purge_key() { - echo "Purge key $2" - # curl \ - # -X POST \ - # -H "Fastly-Key: ${FASTLY_KEY}" \ - # -H "Accept: application/json" \ - # -H "Content-Length: 0" \ - # "https://api.fastly.com/service/$1/purge/$2" + 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() { @@ -288,8 +288,6 @@ jobs: purge_key ${FASTLY_BUILDS_SERVICE_ID} $1 } - cat purge_keys.txt - for key in $(cat purge_keys.txt); do purge "${key}" done From 40f0dda31ec16109763453f67ee599e7046f906a Mon Sep 17 00:00:00 2001 From: Thanabodee Charoenpiriyakij Date: Thu, 26 Sep 2024 23:23:05 +0700 Subject: [PATCH 28/28] Drop utils.sh Signed-off-by: Thanabodee Charoenpiriyakij --- .github/workflows/release.yml | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5ff26180ca5..91619902022 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -170,32 +170,8 @@ jobs: run: | touch purge_keys.txt - - name: Utils.sh - run: | - cat << 'EOF' > utils.sh - 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 - } - EOF - - name: Upload Precompiled to S3 run: | - source utils.sh ref_name=${{ github.ref_name }} mv elixir-otp-*/* .