From b9ac81529c5bef7b530fb9b4779df1affb6e397b Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Wed, 1 May 2024 04:08:10 +0200 Subject: [PATCH] Use Cloudflare and rclone for release artifacts --- .github/workflows/release.yml | 26 +++++++++++++++----------- Makefile | 21 +++++++++++---------- ci/docker/fedora/Dockerfile | 2 +- docs/rclone.conf => rclone.conf | 1 + scripts/runtimes.sh | 10 +++++----- 5 files changed, 33 insertions(+), 27 deletions(-) rename docs/rclone.conf => rclone.conf (76%) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f421ac0e8..d6dbbc7bc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,19 +21,25 @@ jobs: source: runs-on: ubuntu-latest + container: + image: ghcr.io/inko-lang/ci:fedora needs: - lints - linux - mac - freebsd env: - AWS_REGION: eu-west-1 - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + RCLONE_S3_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }} + RCLONE_S3_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }} + RCLONE_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com steps: - uses: actions/checkout@v4 - - run: make release/source - - run: make release/manifest + with: + fetch-depth: 0 + - name: Upload source archive + run: make release/source + - name: Update manifest + run: make release/manifest container: runs-on: ubuntu-latest @@ -76,16 +82,14 @@ jobs: - mac - freebsd env: - AWS_REGION: eu-west-1 - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + RCLONE_S3_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_ACCESS_KEY_ID }} + RCLONE_S3_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_SECRET_ACCESS_KEY }} + RCLONE_S3_ENDPOINT: https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com steps: - - name: Install dependencies - run: microdnf install --quiet --assumeyes awscli2 git tar make - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Generating runtimes + - name: Upload runtimes run: make runtimes docs: diff --git a/Makefile b/Makefile index e82ba7c24..c9861ad20 100644 --- a/Makefile +++ b/Makefile @@ -59,7 +59,8 @@ TMP_DIR := tmp SOURCE_TAR := ${TMP_DIR}/${VERSION}.tar.gz # The path to the versions file. -MANIFEST := ${TMP_DIR}/manifest.txt +MANIFEST_NAME := manifest.txt +MANIFEST := ${TMP_DIR}/${MANIFEST_NAME} build: INKO_STD=${RUNTIME_STD} INKO_RT=${RUNTIME_RT} cargo build --release @@ -84,16 +85,16 @@ ${SOURCE_TAR}: ${TMP_DIR} | gzip > "${@}" release/source: ${SOURCE_TAR} - aws s3 cp --acl public-read "${SOURCE_TAR}" s3://${RELEASES_BUCKET}/ + rclone copy --config rclone.conf --checksum --verbose \ + "${SOURCE_TAR}" "production:${RELEASES_BUCKET}" release/manifest: ${TMP_DIR} - aws s3 ls s3://${RELEASES_BUCKET}/ | \ - grep -oP '(\d+\.\d+\.\d+\.tar.gz)$$' | \ - grep -oP '(\d+\.\d+\.\d+)' | \ - sort > "${MANIFEST}" - aws s3 cp --acl public-read "${MANIFEST}" s3://${RELEASES_BUCKET}/ - aws cloudfront create-invalidation \ - --distribution-id ${RELEASES_CLOUDFRONT_ID} --paths "/*" + rclone copyto --config rclone.conf \ + "production:${RELEASES_BUCKET}/${MANIFEST_NAME}" "${MANIFEST}" + echo "${VERSION}" >> "${MANIFEST}" + sort --version-sort "${MANIFEST}" + rclone copy --config rclone.conf --checksum --verbose \ + "${MANIFEST}" "production:${RELEASES_BUCKET}" release/changelog: clogs "${VERSION}" @@ -151,7 +152,7 @@ docs/watch: cd docs && bash scripts/watch.sh docs/publish: docs/setup docs/build - cd docs && rclone sync --config rclone.conf --checksum --verbose \ + cd docs && rclone sync --config ../rclone.conf --checksum --verbose \ public "production:${DOCS_BUCKET}/manual/${DOCS_FOLDER}" runtimes: diff --git a/ci/docker/fedora/Dockerfile b/ci/docker/fedora/Dockerfile index 150f34148..af7c32752 100644 --- a/ci/docker/fedora/Dockerfile +++ b/ci/docker/fedora/Dockerfile @@ -8,7 +8,7 @@ ENV PATH /opt/cargo/bin:$PATH ENV CARGO_HOME /opt/cargo ENV RUSTUP_HOME /opt/rustup -RUN sudo dnf install --assumeyes --quiet gcc make tar git rustup \ +RUN sudo dnf install --assumeyes --quiet gcc make tar git rustup rclone \ llvm$LLVM_VERSION llvm$LLVM_VERSION-devel \ llvm$LLVM_VERSION-static libstdc++-devel libstdc++-static \ libffi-devel zlib-devel diff --git a/docs/rclone.conf b/rclone.conf similarity index 76% rename from docs/rclone.conf rename to rclone.conf index 082e4b0cd..d91fc838e 100644 --- a/docs/rclone.conf +++ b/rclone.conf @@ -3,3 +3,4 @@ type = s3 provider = Cloudflare env_auth = true region = auto +no_check_bucket = true diff --git a/scripts/runtimes.sh b/scripts/runtimes.sh index cc6c7686f..f8e7acb2a 100755 --- a/scripts/runtimes.sh +++ b/scripts/runtimes.sh @@ -17,8 +17,8 @@ VERSION="${1}" # The directory to place the runtimes in. DIR="tmp/runtimes/${VERSION}" -# The S3 bucket to store the runtime files in. -S3_BUCKET="releases.inko-lang.org" +# The Cloudflare bucket to store the runtime files in. +BUCKET="inko-releases" function rustup_lib { local home @@ -80,6 +80,6 @@ build "aarch64-unknown-linux-musl" "arm64-linux-musl" build "x86_64-apple-darwin" "amd64-mac-native" build "aarch64-apple-darwin" "arm64-mac-native" -# Upload the results to the S3 bucket. -aws s3 sync --no-progress --acl=public-read --cache-control max-age=86400 \ - "${DIR}" "s3://${S3_BUCKET}/runtimes/${VERSION}" +# Upload the results to the bucket. +rclone sync --config rclone.conf --checksum --verbose \ + "${DIR}" "production:${BUCKET}/runtimes/${VERSION}"