-
Notifications
You must be signed in to change notification settings - Fork 1.6k
82 lines (72 loc) · 3.17 KB
/
nightly-release.yaml
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
name: Nightly Development Release
on:
schedule:
- cron: "0 8 * * *" # Run every day at 12AM PST (8AM UTC)
workflow_dispatch:
jobs:
nightly-release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
- name: Get latest tag
id: get_latest_tag
run: |
# Retrieve the latest tag by:
# 1. Listing all tags
# 2. Filtering for tags matching the pattern `[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$`
# 3. Filtering out tags containing `rc`, `alpha`, `beta`, or `post`
# 4. Replacing `.dev` with `~dev` for sorting purposes
# 5. Sorting the tags in version order
# 6. Replacing `~dev` with `.dev`
# 7. Taking the last tag
latest_tag=$(git tag -l | grep -E '^[0-9]+\.[0-9]+\.[0-9]+(\.dev[0-9]+)?$' | grep -Ev 'rc|alpha|beta|post' | sed 's/\.dev/~dev/' | sort --version-sort | sed 's/~dev/.dev/' | tail -n1)
if [ -z "$latest_tag" ]; then
echo "No matching tags found."
exit 1
fi
echo "latest_tag=$latest_tag" >> $GITHUB_OUTPUT
- name: Check for changes since latest tag
id: check_changes
run: |
latest_tag=${{ steps.get_latest_tag.outputs.latest_tag }}
if git diff --exit-code $latest_tag HEAD -- '*.py' setup.py requirements.txt requirements-client.txt ui; then
echo "SHOULD_CREATE_RELEASE=false" >> $GITHUB_OUTPUT
echo "No changes in .py files or dependencies since the latest tag."
else
echo "SHOULD_CREATE_RELEASE=true" >> $GITHUB_OUTPUT
echo "Changes detected since the latest tag."
fi
- name: Determine next development release tag
id: next_dev_version
if: steps.check_changes.outputs.SHOULD_CREATE_RELEASE == 'true'
run: |
latest_tag=${{ steps.get_latest_tag.outputs.latest_tag }}
# Extract the components of the latest tag
components=$(echo $latest_tag | sed -nE 's/^([0-9]+)\.([0-9]+)\.([0-9]+)(\.dev([0-9]+))?$/\1 \2 \3 \5/p')
read -r major minor micro prev_counter <<< "$components"
if [ -z "$prev_counter" ]; then
# This is the dev first release for the next version
micro=$((micro + 1))
counter=1
else
# There have been dev releases for this version
counter=$((prev_counter + 1))
fi
next_tag=${major}.${minor}.${micro}.dev${counter}
echo "next_tag=$next_tag" >> $GITHUB_OUTPUT
echo "Next tag is $next_tag"
- name: Create development release
id: create_development_release
if: steps.check_changes.outputs.SHOULD_CREATE_RELEASE == 'true'
uses: softprops/action-gh-release@v2
with:
name: "${{ steps.next_dev_version.outputs.next_tag }}: Nightly Development Release"
tag_name: ${{ steps.next_dev_version.outputs.next_tag }}
draft: false
prerelease: true
generate_release_notes: true
token: ${{ secrets.UI_COMPONENTS_CONTENTS_PRS_RW }}