Skip to content

Bundle and Release

Bundle and Release #12

Workflow file for this run

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 bundle
env:
GITHUB_TOKEN: ${{ secrets.ACCOUNT_TOKEN }}
run: |
python .github/scripts/process_components.py
- name: Generate release name and tag
id: release_info
run: |
echo "Starting release name and tag generation..."
YEAR=$(date +%Y)
echo "Current year: $YEAR"
WEEK=$(date +%V)
echo "Current week number: $WEEK"
# Get the current branch name
BRANCH=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $BRANCH"
# Calculate the start of the week (Monday)
WEEK_START=$(date -d "last monday" +%Y-%m-%d)
echo "Start of the week: $WEEK_START"
# Count tags on this branch created since the start of the week
RELEASE_IN_WEEK=$(git tag --list "v${YEAR}.${WEEK}.*" --merged "$BRANCH" --sort=creatordate |
git for-each-ref --format="%(creatordate:short)%(refname:short)" --stdin |
awk -v start="$WEEK_START" '$1 >= start {print $2}' |
wc -l)
# Increment the count for the new release
RELEASE_IN_WEEK=$((RELEASE_IN_WEEK + 1))
echo "Release number in this week: $RELEASE_IN_WEEK"
RELEASE_NAME="${YEAR}.${WEEK}.${RELEASE_IN_WEEK}"
echo "Generated RELEASE_NAME: $RELEASE_NAME"
TAG_NAME="v${RELEASE_NAME}"
echo "Generated TAG_NAME: $TAG_NAME"
echo "RELEASE_NAME=${RELEASE_NAME}" >> $GITHUB_OUTPUT
echo "TAG_NAME=${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 Bundle to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bundle.zip
asset_name: bundle.zip
asset_content_type: application/zip
- name: Upload Individual Files to Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for file in release_files/*; do
filename=$(basename "$file")
curl -X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: $(file -b --mime-type "$file")" \
-H "Accept: application/vnd.github.v3+json" \
--data-binary @"$file" \
"${{ steps.create_release.outputs.upload_url }}?name=$filename"
done