Skip to content

Commit

Permalink
+ latest symlink for release artifacts, + artifact last_modified
Browse files Browse the repository at this point in the history
  • Loading branch information
kvs96 committed Apr 26, 2024
1 parent 2e31ae7 commit 96e82f9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
35 changes: 32 additions & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
description: 'Tag to use for the build. Example: v1.0.0. *Null = master'
required: false
default: ''
latest:
description: 'Tag as latest ?'
type: boolean
required: false
default: false

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -67,6 +72,9 @@ jobs:
wget https://github.com/protocolbuffers/protobuf/releases/download/v3.20.2/protoc-3.20.2-linux-x86_64.zip
unzip protoc-3.20.2-linux-x86_64.zip -d /usr/local
rm protoc-3.20.2-linux-x86_64.zip
wget https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip
unzip awscli-exe-linux-x86_64.zip
./aws/install
- name: Checkout `gear-tech/gear`
uses: actions/checkout@v3
Expand Down Expand Up @@ -144,6 +152,25 @@ jobs:
if-no-files-found: ignore
path: ${{ env.ARTIFACT_NAME }}

- name: Update latest symlink for release artifacts (Linux/macOS)
if: >
github.event.inputs.release_version != '' &&
github.event.inputs.latest == 'true' &&
runner.os != 'Windows'
run: |
latest_artifact=$(aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --query "reverse(sort_by(Contents, &LastModified))[?contains(Key, 'gear-${{ github.event.inputs.release_version }}-${{ matrix.target }}')].[Key]" --output text)
aws s3api put-object --bucket ${{ env.AWS_BUCKET }} --key gear-latest-${{ matrix.target }}.${{ matrix.file_ext }} --website-redirect-location /$latest_artifact
- name: Update latest symlink for release artifacts (Windows)
if: >
github.event.inputs.release_version != '' &&
github.event.inputs.latest == 'true' &&
runner.os == 'Windows'
run: |
$latest_artifact = aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --query "reverse(sort_by(Contents, &LastModified))[?contains(Key, 'gear-${{ github.event.inputs.release_version }}-${{ matrix.target }}')].[Key]" --output text
aws s3api put-object --bucket ${{ env.AWS_BUCKET }} --key "gear-latest-${{ matrix.target }}.${{ matrix.file_ext }}" --website-redirect-location "/$latest_artifact"
shell: pwsh

publish:
name: Publish artifacts
needs: build
Expand Down Expand Up @@ -190,15 +217,16 @@ jobs:
<h1>Gear Builds</h1>
</div>
<div class='builds'>
<h3 id='gear-nightly'>Nightly Builds - <a href='#gear-nightly'>$(date -u +'%d.%m.%Y %H:%M:%S UTC')</a></h3>
<h3 id='gear-nightly'>Nightly Builds<a href='#gear-nightly'></a></h3>
<ul>" > src/index.html
artifacts=$(aws s3api list-objects --bucket ${{ env.AWS_BUCKET }} --region ${{ env.AWS_REGION }} --query 'reverse(sort_by(Contents, &LastModified))[].Key' | jq -r '.[]' | grep gear-n)
for artifact in $artifacts; do
filename=$(basename "$artifact")
filesize_bytes=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'ContentLength' --output text)
filesize_mb=$(echo "$filesize_bytes / 1024 / 1024" | bc -l | xargs printf "%.2f")
echo " <li><a href='https://${{ env.AWS_BUCKET }}.s3.amazonaws.com/$filename'>$filename</a> ($filesize_mb MB)</li>"
last_modified=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'LastModified' --output text | xargs -I {} date -u -d {} "+%d.%m.%Y %H:%M:%S UTC")
echo " <li><a href='https://${{ env.AWS_BUCKET }}.s3.amazonaws.com/$filename'>$filename</a> ($filesize_mb MB, $last_modified)</li>"
done >> src/index.html
echo " </ul>
</div>" >> src/index.html
Expand All @@ -213,7 +241,8 @@ jobs:
filename=$(basename "$artifact")
filesize_bytes=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'ContentLength' --output text)
filesize_mb=$(echo "$filesize_bytes / 1024 / 1024" | bc -l | xargs printf "%.2f")
echo " <li><a href='https://${{ env.AWS_BUCKET }}.s3.amazonaws.com/$filename'>$filename</a> ($filesize_mb MB)</li>"
last_modified=$(aws s3api head-object --bucket ${{ env.AWS_BUCKET }} --key "$artifact" --region ${{ env.AWS_REGION }} --query 'LastModified' --output text | xargs -I {} date -u -d {} "+%d.%m.%Y %H:%M:%S UTC")
echo " <li><a href='https://${{ env.AWS_BUCKET }}.s3.amazonaws.com/$filename'>$filename</a> ($filesize_mb MB, $last_modified)</li>"
done >> src/index.html
echo " </ul>
</div>"
Expand Down
4 changes: 2 additions & 2 deletions src/static/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ body {
padding-bottom: 12px;
margin: 0 auto 24px auto;
width: 100%;
max-width: 480px;
max-width: 800px;
margin-bottom: 8px;
}
.footer {
Expand All @@ -24,7 +24,7 @@ body {
flex-direction: column;
align-items: center;
width: 100%;
max-width: 480px;
max-width: 800px;
margin: 0 auto;
padding: 16px 0;
}
Expand Down

0 comments on commit 96e82f9

Please sign in to comment.