Skip to content

Commit

Permalink
Use Cloudflare and rclone for release artifacts
Browse files Browse the repository at this point in the history
  • Loading branch information
yorickpeterse committed May 1, 2024
1 parent e00b69b commit b9ac815
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 27 deletions.
26 changes: 15 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
21 changes: 11 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}"
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion ci/docker/fedora/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions docs/rclone.conf → rclone.conf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ type = s3
provider = Cloudflare
env_auth = true
region = auto
no_check_bucket = true
10 changes: 5 additions & 5 deletions scripts/runtimes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}"

0 comments on commit b9ac815

Please sign in to comment.