diff --git a/.rwx/package.yml b/.rwx/package.yml index 83fd7b5..0c0ffb6 100644 --- a/.rwx/package.yml +++ b/.rwx/package.yml @@ -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 diff --git a/rwx/package/README.md b/rwx/package/README.md new file mode 100644 index 0000000..f19cf6e --- /dev/null +++ b/rwx/package/README.md @@ -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 +``` diff --git a/rwx/package/rwx-package.yml b/rwx/package/rwx-package.yml new file mode 100644 index 0000000..727b4f9 --- /dev/null +++ b/rwx/package/rwx-package.yml @@ -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] diff --git a/rwx/package/rwx-test.yml b/rwx/package/rwx-test.yml new file mode 100644 index 0000000..a25a3b7 --- /dev/null +++ b/rwx/package/rwx-test.yml @@ -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