-
Notifications
You must be signed in to change notification settings - Fork 2
132 lines (108 loc) · 4.17 KB
/
bundle-release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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."