Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions .rwx/package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,9 @@ tasks:

- key: package
use: [build]
call: 4ad359d09e34defc6da32ad46013c07cba6ae9a8b18b58351d095ce90beadcd9
call: 9594e0f1eba63f75513d432a07a440828dd41f6b01b48206e57c9cfc6313bd72
with:
directory: ${{ init.directory }}
rwx-access-token: ${{ vaults.mint_leaves_development.secrets.RWX_ACCESS_TOKEN }}
timestamp: ${{ tasks.timestamp.values.timestamp }}

- key: generate-test
Expand Down
15 changes: 15 additions & 0 deletions rwx/package/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# rwx/package

Build and upload an RWX package.

This package zips a directory and uploads it to the RWX package registry, returning the content digest of the uploaded package.

## Usage

```yaml
tasks:
- key: package
call: rwx/package 1.0.0
with:
directory: path/to/package
```
58 changes: 58 additions & 0 deletions rwx/package/rwx-package.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: rwx/package
version: 1.0.0
description: Build and upload an RWX package
source_code_url: https://github.com/rwx-cloud/packages/tree/main/rwx/package
issue_tracker_url: https://github.com/rwx-cloud/packages/issues

parameters:
directory:
description: Path to the directory containing the package files
default: .
timestamp:
description: "Timestamp to normalize file modification times before zipping (format: YYYYMMDDHHmm). Ensures deterministic zip output for content-based caching."

tasks:
- key: system-packages
run: |
if command -v zip &> /dev/null; then
echo "zip is already installed"
exit 0
fi
sudo apt-get update
sudo apt-get install zip
sudo apt-get clean

- key: zip
use: system-packages
run: |
if [[ -n "$TIMESTAMP" ]]; then
echo "Setting timestamp on files to $TIMESTAMP"
find "$DIRECTORY" -exec touch -t "$TIMESTAMP" {} \;
fi
workspace=$(pwd)
cd "$DIRECTORY" && zip -X -r "$workspace/package.zip" .
filter:
- ${{ params.directory }}
env:
DIRECTORY: ${{ params.directory }}
TIMESTAMP: ${{ params.timestamp }}

- key: upload
use: zip
run: |
curl \
--request POST \
--fail-with-body \
--header "Authorization: Bearer $RWX_ACCESS_TOKEN" \
--header 'Accept: application/json' \
-F 'file=@package.zip' \
https://cloud.rwx.com/mint/api/leaves | tee result.json

digest=$(jq -r '.digest' result.json)
echo "Uploaded package with digest: $digest"
echo -n "$digest" > "$RWX_VALUES/digest"
filter:
- package.zip

outputs:
values-from: [upload]
19 changes: 19 additions & 0 deletions rwx/package/rwx-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
base:
image: ${{ init.base-image }}
config: ${{ init.base-config }}

tasks:
- key: code
call: git/clone 2.0.3
with:
repository: https://github.com/rwx-cloud/packages.git
ref: dan/package

- key: test
use: code
call: ${{ init.package-digest }}
with:
directory: rwx/package
timestamp: ${{ date("%Y%m%d%H%M") }}
filter:
- rwx/package