diff options
author | Josep Lluis Giralt D'Lacoste ( Pep ) <6720169+gilacost@users.noreply.github.com> | 2022-11-19 10:39:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-19 09:39:38 +0100 |
commit | 1c6971fc787aacf9b5375d6ae25271b9b3a9db5c (patch) | |
tree | fda2457bafebc9a1529a16c99fd3514fc5001746 /.github | |
parent | 7a7ca7e9789e91bc3a4002ca829766a6a0ce7dac (diff) | |
download | elixir-1c6971fc787aacf9b5375d6ae25271b9b3a9db5c.tar.gz |
Publish precompiled to s3 on releasing (#12242)
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/repo.hex.pm.yml | 75 |
1 files changed, 61 insertions, 14 deletions
diff --git a/.github/workflows/repo.hex.pm.yml b/.github/workflows/repo.hex.pm.yml index a66557253..5194f1a8f 100644 --- a/.github/workflows/repo.hex.pm.yml +++ b/.github/workflows/repo.hex.pm.yml @@ -5,6 +5,8 @@ on: branches: - main - v*.* + tags: + - v* env: ELIXIR_OPTS: "--warnings-as-errors" @@ -19,10 +21,12 @@ jobs: include: - otp: 24 otp_version: 24.3 + upload_generic_version: upload_generic_version - otp: 25 otp_version: 25.0 build_docs: build_docs runs-on: ubuntu-20.04 + concurrency: builds_txt steps: - uses: actions/checkout@v3 with: @@ -32,6 +36,26 @@ jobs: otp_version: ${{ matrix.otp_version }} otp: ${{ matrix.otp }} build_docs: ${{ matrix.build_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/${FASTLY_SERVICE_ID}/purge/$1" + } + function purge() { + purge_key $1 + sleep 2 + purge_key $1 + sleep 2 + purge_key $1 + } + EOF + chmod +x utils.sh - name: Upload Docs to S3 if: ${{ matrix.build_docs }} env: @@ -42,15 +66,7 @@ jobs: FASTLY_SERVICE_ID: ${{ secrets.HEX_FASTLY_SERVICE_ID }} FASTLY_KEY: ${{ secrets.HEX_FASTLY_KEY }} 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/${FASTLY_SERVICE_ID}/purge/$1" - } - + source utils.sh version=$(echo ${{ github.ref_name }} | sed -e 's/^v//g') for f in doc/*; do if [ -d "$f" ]; then @@ -61,10 +77,41 @@ jobs: 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_key "${surrogate_key}" - sleep 2 - purge_key "${surrogate_key}" - sleep 2 - purge_key "${surrogate_key}" + 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 }} + run: | + 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","surrogate-control":"public,max-age=604800"}' + 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","surrogate-control":"public,max-age=604800"}' + 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_SERVICE_ID: ${{ secrets.HEX_FASTLY_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","surrogate-control":"public,max-age=604800"}' + purge builds |