mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
feat: generate indexes for the release storage
This commit is contained in:
@@ -66,11 +66,27 @@ jobs:
|
||||
role-to-assume: arn:aws:iam::538326561891:role/gh_actions_suite_production
|
||||
aws-region: eu-central-1
|
||||
|
||||
- name: Extract suite desktop version
|
||||
id: extract-version
|
||||
run: |
|
||||
echo "VERSION=$(jq -r .suiteVersion packages/suite/package.json)" >> $GITHUB_ENV
|
||||
|
||||
- name: Sync suite-desktop latest
|
||||
run: |
|
||||
aws s3 sync --delete s3://staging-data.trezor.io/suite/releases/desktop/latest/ s3://data.trezor.io/suite/releases/desktop/latest/
|
||||
aws cloudfront create-invalidation --distribution-id E1ERY5K2OTKKI1 --paths "/suite/releases/desktop/latest/*"
|
||||
|
||||
# Uploads the version folder to data.trezor.io together with the production latest release
|
||||
- name: Sync suite-desktop version folder
|
||||
run: |
|
||||
aws s3 sync --delete s3://staging-data.trezor.io/suite/releases/desktop/v${{ steps.extract-version.outputs.VERSION }}/ s3://data.trezor.io/suite/releases/desktop/v${{ steps.extract-version.outputs.VERSION }}/
|
||||
|
||||
# Generate index.html for desktop release folders
|
||||
- name: Generate index.html for desktop release folders
|
||||
run: |
|
||||
./scripts/generate-s3-directory-index.sh data.trezor.io suite/releases/desktop
|
||||
aws cloudfront create-invalidation --distribution-id E1ERY5K2OTKKI1 --paths "/suite/releases/desktop/*"
|
||||
|
||||
sync-staging-website:
|
||||
if: ${{ github.event.inputs.publishWebProduction == 'true' && github.repository == 'trezor/trezor-suite-release' }}
|
||||
name: "Syncing suite-web staging to production"
|
||||
|
||||
@@ -145,14 +145,23 @@ jobs:
|
||||
aws s3 sync --delete ./trezor-suite-files s3://staging-data.trezor.io/suite/releases/desktop/canary
|
||||
|
||||
- name: Set staging percentage
|
||||
working-directory:
|
||||
run: cd ./trezor-suite-files && ../scripts/ci/set-staging-percentage.sh 20
|
||||
|
||||
- name: Extract suite desktop version
|
||||
id: extract-version
|
||||
run: |
|
||||
echo "VERSION=$(jq -r .suiteVersion packages/suite/package.json)" >> $GITHUB_ENV
|
||||
|
||||
- name: Upload suite-desktop to staging-data.trezor.io latest
|
||||
run: |
|
||||
VERSION=$(jq -r .suiteVersion packages/suite/package.json)
|
||||
aws s3 sync --delete ./trezor-suite-files s3://staging-data.trezor.io/suite/releases/desktop/latest
|
||||
aws s3 sync --delete s3://staging-data.trezor.io/suite/releases/desktop/latest/ s3://staging-data.trezor.io/suite/releases/desktop/v${VERSION}/
|
||||
aws s3 sync --delete s3://staging-data.trezor.io/suite/releases/desktop/latest/ s3://staging-data.trezor.io/suite/releases/desktop/v${{ steps.extract-version.outputs.VERSION }}/
|
||||
|
||||
- name: Generate index.html for latest, canary and version folders
|
||||
run: |
|
||||
./scripts/generate-s3-index.sh staging-data.trezor.io suite/releases/desktop/latest
|
||||
./scripts/generate-s3-index.sh staging-data.trezor.io suite/releases/desktop/canary
|
||||
./scripts/generate-s3-index.sh staging-data.trezor.io suite/releases/desktop/v${{ steps.extract-version.outputs.VERSION }}
|
||||
|
||||
build-web:
|
||||
if: github.repository == 'trezor/trezor-suite-release'
|
||||
|
||||
@@ -133,6 +133,15 @@ jobs:
|
||||
run: |
|
||||
aws s3 cp "./Trezor-Suite-${{ steps.get_version.outputs.app_version }}.apk" s3://data.trezor.io/suite/releases/mobile/v${{ steps.get_version.outputs.app_version }}/
|
||||
|
||||
- name: Generate index.html for mobile releases
|
||||
run: |
|
||||
./scripts/generate-s3-index.sh data.trezor.io suite/releases/mobile/v${{ steps.get_version.outputs.app_version }}
|
||||
|
||||
- name: Generate index.html for mobile releases root
|
||||
run: |
|
||||
./scripts/generate-s3-directory-index.sh data.trezor.io suite/releases/mobile
|
||||
aws cloudfront create-invalidation --distribution-id E1ERY5K2OTKKI1 --paths "/suite/releases/mobile/*"
|
||||
|
||||
- name: Generate GitHub App token
|
||||
id: trezor-bot-token
|
||||
uses: actions/create-github-app-token@v1
|
||||
|
||||
142
scripts/generate-s3-directory-index.sh
Executable file
142
scripts/generate-s3-directory-index.sh
Executable file
@@ -0,0 +1,142 @@
|
||||
#!/bin/bash
|
||||
|
||||
# generate-s3-directory-index.sh
|
||||
#
|
||||
# This script generates an index.html file for AWS S3 directories to list subdirectories
|
||||
# Designed to be used within GitHub Actions workflows
|
||||
#
|
||||
# Usage:
|
||||
# ./generate-s3-directory-index.sh <bucket> <path>
|
||||
#
|
||||
# Example:
|
||||
# ./generate-s3-directory-index.sh data.trezor.io suite/releases/desktop
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: ./generate-s3-directory-index.sh <bucket> <path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUCKET=$1
|
||||
S3_PATH=$2
|
||||
|
||||
echo "Generating directory index.html for s3://$BUCKET/$S3_PATH"
|
||||
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
TEMP_FILE="$TEMP_DIR/index.html"
|
||||
TEMP_LIST="$TEMP_DIR/s3_list.txt"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$TEMP_DIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Listing directories in s3://$BUCKET/$S3_PATH/..."
|
||||
|
||||
aws s3 ls "s3://$BUCKET/$S3_PATH/" | grep "PRE" >"$TEMP_LIST"
|
||||
if ! aws s3 ls "s3://$BUCKET/$S3_PATH/" | grep "PRE" >"$TEMP_LIST"; then
|
||||
echo "Error listing S3 directories"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "AWS S3 output:"
|
||||
cat "$TEMP_LIST"
|
||||
|
||||
cat >"$TEMP_FILE" <<EOF
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Index of $S3_PATH</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.4;
|
||||
color: #333;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
h1 {
|
||||
border-bottom: 1px solid #eaecef;
|
||||
padding-bottom: 5px;
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
th, td {
|
||||
text-align: left;
|
||||
padding: 4px 8px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
th {
|
||||
background-color: #f6f8fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
a {
|
||||
color: #0366d6;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.dir a:before {
|
||||
content: "📁 ";
|
||||
}
|
||||
.footer {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Index of $S3_PATH</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="dir"><a href="../">Parent Directory</a></td>
|
||||
</tr>
|
||||
EOF
|
||||
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
|
||||
echo "Processing line: $line"
|
||||
|
||||
if [[ $line =~ PRE\ (.*)/ ]]; then
|
||||
dirname="${BASH_REMATCH[1]}"
|
||||
echo "Found directory: $dirname"
|
||||
[[ "$dirname" == "index.html" ]] && continue
|
||||
|
||||
printf " <tr>\n <td class=\"dir\"><a href=\"%s/\">%s/</a></td>\n </tr>\n" "$dirname" "$dirname" >>"$TEMP_FILE"
|
||||
else
|
||||
echo "Line did not match expected format: $line"
|
||||
fi
|
||||
done <"$TEMP_LIST"
|
||||
|
||||
CURRENT_DATE=$(date "+%Y-%m-%d %H:%M:%S %Z")
|
||||
|
||||
cat >>"$TEMP_FILE" <<EOF
|
||||
</table>
|
||||
<div class="footer">Generated by Trezor Suite release tools on $CURRENT_DATE</div>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
echo "Uploading index.html to s3://$BUCKET/$S3_PATH/index.html..."
|
||||
if aws s3 cp "$TEMP_FILE" "s3://$BUCKET/$S3_PATH/index.html"; then
|
||||
echo "Successfully generated and uploaded index.html"
|
||||
else
|
||||
echo "Failed to upload index.html"
|
||||
exit 1
|
||||
fi
|
||||
175
scripts/generate-s3-index.sh
Executable file
175
scripts/generate-s3-index.sh
Executable file
@@ -0,0 +1,175 @@
|
||||
#!/bin/bash
|
||||
|
||||
# This script generates an index.html file for trezor suite release directories
|
||||
# Designed to be used within GitHub Actions workflows
|
||||
#
|
||||
# Usage:
|
||||
# ./generate-s3-index.sh <bucket> <path>
|
||||
#
|
||||
# Example:
|
||||
# ./generate-s3-index.sh data.trezor.io suite/releases/desktop/latest
|
||||
# This will generate index.html for the latest release of Trezor Suite Desktop
|
||||
|
||||
set -e
|
||||
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: ./generate-s3-index.sh <bucket> <path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUCKET=$1
|
||||
S3_PATH=$2
|
||||
|
||||
echo "Generating index.html for s3://$BUCKET/$S3_PATH"
|
||||
|
||||
# Create a temporary directory
|
||||
TEMP_DIR=$(mktemp -d)
|
||||
TEMP_FILE="$TEMP_DIR/index.html"
|
||||
TEMP_LIST="$TEMP_DIR/s3_list.txt"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$TEMP_DIR"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Listing objects in s3://$BUCKET/$S3_PATH/..."
|
||||
|
||||
aws s3 ls "s3://$BUCKET/$S3_PATH/" >"$TEMP_LIST"
|
||||
if ! aws s3 ls "s3://$BUCKET/$S3_PATH/" >"$TEMP_LIST"; then
|
||||
echo "Error listing S3 objects"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "AWS S3 output:"
|
||||
cat "$TEMP_LIST"
|
||||
|
||||
cat >"$TEMP_FILE" <<EOF
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Index of $S3_PATH</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
||||
line-height: 1.4;
|
||||
color: #333;
|
||||
max-width: 1000px;
|
||||
margin: 0 auto;
|
||||
padding: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
h1 {
|
||||
border-bottom: 1px solid #eaecef;
|
||||
padding-bottom: 5px;
|
||||
margin: 0 0 10px 0;
|
||||
font-size: 18px;
|
||||
}
|
||||
table {
|
||||
width: 100%;
|
||||
border-collapse: collapse;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
th, td {
|
||||
text-align: left;
|
||||
padding: 4px 8px;
|
||||
border-bottom: 1px solid #eee;
|
||||
}
|
||||
th {
|
||||
background-color: #f6f8fa;
|
||||
font-weight: 600;
|
||||
}
|
||||
a {
|
||||
color: #0366d6;
|
||||
text-decoration: none;
|
||||
}
|
||||
a:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.dir a:before {
|
||||
content: "📁 ";
|
||||
}
|
||||
.file a:before {
|
||||
content: "📄 ";
|
||||
}
|
||||
.size {
|
||||
text-align: right;
|
||||
white-space: nowrap;
|
||||
width: 100px;
|
||||
}
|
||||
.footer {
|
||||
font-size: 12px;
|
||||
color: #666;
|
||||
margin-top: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Index of $S3_PATH</h1>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th class="size">Size</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="dir"><a href="../">Parent Directory</a></td>
|
||||
<td class="size">-</td>
|
||||
</tr>
|
||||
EOF
|
||||
|
||||
while IFS= read -r line; do
|
||||
[[ -z "$line" ]] && continue
|
||||
|
||||
echo "Processing line: $line"
|
||||
|
||||
if [[ $line =~ [0-9]{4}-[0-9]{2}-[0-9]{2}\ [0-9]{2}:[0-9]{2}:[0-9]{2}\ +([0-9]+)\ +(.*) ]]; then
|
||||
size="${BASH_REMATCH[1]}"
|
||||
filename="${BASH_REMATCH[2]}"
|
||||
|
||||
echo "Found file: $filename (size: $size)"
|
||||
|
||||
[[ "$filename" == "index.html" ]] && continue
|
||||
|
||||
if ((size == 0)); then
|
||||
formatted_size="0 B"
|
||||
else
|
||||
units=("B" "KB" "MB" "GB" "TB")
|
||||
power=0
|
||||
size_num=$size
|
||||
|
||||
while ((size_num >= 1024 && power < 4)); do
|
||||
size_num=$((size_num / 1024))
|
||||
((power++))
|
||||
done
|
||||
|
||||
if ((power > 0)); then
|
||||
size_decimal=$(echo "scale=2; $size / (1024 ^ $power)" | bc)
|
||||
formatted_size="$size_decimal ${units[$power]}"
|
||||
else
|
||||
formatted_size="$size ${units[$power]}"
|
||||
fi
|
||||
fi
|
||||
|
||||
printf " <tr>\n <td class=\"file\"><a href=\"%s\">%s</a></td>\n <td class=\"size\">%s</td>\n </tr>\n" "$filename" "$filename" "$formatted_size" >>"$TEMP_FILE"
|
||||
else
|
||||
echo "Line did not match expected format: $line"
|
||||
fi
|
||||
done <"$TEMP_LIST"
|
||||
|
||||
CURRENT_DATE=$(date "+%Y-%m-%d %H:%M:%S %Z")
|
||||
|
||||
cat >>"$TEMP_FILE" <<EOF
|
||||
</table>
|
||||
<div class="footer">Generated by Trezor Suite release tools on $CURRENT_DATE</div>
|
||||
</body>
|
||||
</html>
|
||||
EOF
|
||||
|
||||
echo "Uploading index.html to s3://$BUCKET/$S3_PATH/index.html"
|
||||
if aws s3 cp "$TEMP_FILE" "s3://$BUCKET/$S3_PATH/index.html"; then
|
||||
echo "Successfully generated and uploaded index.html"
|
||||
else
|
||||
echo "Failed to upload index.html"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user