fix: metrics download url #140
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Bundle and Release | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
bundle-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.x" | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install PyYAML requests | |
- name: Process components and create bundles | |
env: | |
GITHUB_TOKEN: ${{ secrets.ACCOUNT_TOKEN }} | |
run: | | |
python .github/scripts/process_components.py | |
- name: Get Commit Hash | |
id: commit_hash | |
run: echo "COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Generate release name and tag | |
id: release_info | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
set -e # Exit immediately if a command exits with a non-zero status | |
echo "Starting release name and tag generation..." | |
# Get ISO year and week | |
ISO_YEAR=$(date +%G) # ISO year | |
ISO_WEEK=$(date +%V) # ISO week number | |
# Replace YEAR and WEEK assignments | |
YEAR=$ISO_YEAR | |
WEEK=$ISO_WEEK | |
COMMIT_HASH=$(git rev-parse --short HEAD) | |
# Get the count of releases for the current year and week | |
RELEASE_COUNT=$(gh release list --limit 1000 | grep -c "v${YEAR}.${WEEK}" || true) | |
# Ensure RELEASE_COUNT is a single line, contains only digits, and is at least 0 | |
RELEASE_COUNT=$(echo "$RELEASE_COUNT" | tr -d '\n' | grep -oE '[0-9]+' || echo 0) | |
RELEASE_COUNT=$((RELEASE_COUNT + 1)) | |
echo "Debug: RELEASE_COUNT = $RELEASE_COUNT" | |
# Construct the release name and tag | |
RELEASE_NAME="${YEAR}.${WEEK}.${RELEASE_COUNT}.dev-${COMMIT_HASH}" | |
TAG_NAME="v${RELEASE_NAME}" | |
# Use printf to ensure no unwanted newlines | |
{ | |
printf "RELEASE_NAME=%s\n" "$RELEASE_NAME" | |
printf "TAG_NAME=%s\n" "$TAG_NAME" | |
} >> "$GITHUB_OUTPUT" | |
echo "Release information set:" | |
echo " RELEASE_NAME: $RELEASE_NAME" | |
echo " TAG_NAME: $TAG_NAME" | |
echo "Release name and tag generation completed." | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.release_info.outputs.TAG_NAME }} | |
release_name: Release ${{ steps.release_info.outputs.RELEASE_NAME }} | |
draft: false | |
prerelease: false | |
- name: Upload Bundles to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Starting bundle uploads..." | |
for bundle in *.zip; do | |
if [ -f "$bundle" ]; then | |
echo "Uploading bundle: $bundle" | |
gh release upload "${{ steps.release_info.outputs.TAG_NAME }}" "$bundle" --clobber | |
if [ $? -eq 0 ]; then | |
echo "Successfully uploaded $bundle" | |
else | |
echo "Failed to upload $bundle" | |
echo "Aborting further uploads." | |
exit 1 | |
fi | |
fi | |
done | |
echo "All bundle uploads completed successfully." | |
- name: Upload Individual Files to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
echo "Starting individual file uploads..." | |
for file in release_files/*; do | |
filename=$(basename "$file") | |
filesize=$(du -h "$file" | cut -f1) | |
echo "Uploading $filename (Size: $filesize)..." | |
gh release upload "${{ steps.release_info.outputs.TAG_NAME }}" "$file" --clobber | |
if [ $? -eq 0 ]; then | |
echo "Successfully uploaded $filename" | |
else | |
echo "Failed to upload $filename" | |
echo "Aborting further uploads." | |
exit 1 | |
fi | |
done | |
echo "All individual file uploads completed successfully." |