-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (124 loc) · 4.69 KB
/
nightly.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Nightly branch
on:
workflow_dispatch:
pull_request:
types:
- opened
- synchronize
- reopened
- edited
push:
branches:
- main
schedule:
- cron: "0 5 * * *" # 0500 UTC every day
jobs:
# Create snapshot of latest main or release branch for nightly build
nightly-snapshot:
name: Update nightly branch
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RELEASE_PLZ_TOKEN }}
- name: Choose base commit for nightly snapshot
id: choose-base
env:
GH_EVENT_NAME: ${{ github.event_name }}
run: |
echo "Event triggered by $GH_EVENT_NAME"
echo
echo "Listing branches on remote"
echo
git --no-pager branch --remote | sed 's|origin/||'
echo
git checkout -b nightly --track origin/nightly
OLD_BASE_COMMIT=$(git log nightly --skip=1 -n 1 --format=%H)
echo "Nightly commit ID is $OLD_BASE_COMMIT"
LATEST_RELEASE_PLZ=$(git --no-pager branch --format="%(refname:short)" --remote |
sed 's|origin/||' |
grep -E '^release-plz-20' |
sort -r |
head -n 1)
if [ -z "$LATEST_RELEASE_PLZ" ]; then
echo "No release-plz branch; using main"
git checkout -b main --track main
BASE_BRANCH=main;
else
echo "Found RP branch $LATEST_RELEASE_PLZ; comparing against main"
git checkout -b "$LATEST_RELEASE_PLZ" --track "origin/$LATEST_RELEASE_PLZ"
if git show-ref --verify --quiet refs/heads/main; then
echo "Branch 'main' already exists locally";
else
git checkout -b main --track origin/main;
fi
export RP_TS=$(git log -1 --format=%cd --date=iso-strict $LATEST_RELEASE_PLZ)
export MAIN_TS=$(git log -1 --format=%cd --date=iso-strict main)
echo "Branch $LATEST_RELEASE_PLZ updated at $RP_TS"
echo "Branch main updated at $MAIN_TS"
if [[ "$RP_TS" > "$MAIN_TS" ]]; then
git checkout $LATEST_RELEASE_PLZ
BASE_BRANCH=$LATEST_RELEASE_PLZ;
else
git checkout main
BASE_BRANCH=main;
fi
fi
NEW_BASE_COMMIT=$(git log $BASE_BRANCH -n 1 --format=%H)
echo "Choosing base branch $BASE_BRANCH because it's newer"
echo "$BASE_BRANCH commit ID is $NEW_BASE_COMMIT"
if [[ "$OLD_BASE_COMMIT" == "$NEW_BASE_COMMIT" && "$GH_EVENT_NAME" == "pull_request" ]]; then
echo "Nightly already points to same base; leave unchanged";
echo "base-commit=skip" >> "$GITHUB_OUTPUT"
exit 0
elif [[ "$GH_EVENT_NAME" == "push" ]]; then
LATEST_TAG=$(git describe --tags --abbrev=0)
echo Looking for non-chore commits since last tag
echo
git --no-pager log --pretty=format:"%s" $LATEST_TAG..HEAD | grep -v "^chore"
if [ $? -eq 0 ]; then
echo
echo "Found non-chore commits; expecting release-plz to create a new release branch."
echo "base-commit=skip" >> "$GITHUB_OUTPUT"
exit 0
else
echo "Push to main, but there are only chore commits since last tag."
echo "Not expecting a new release branch"
echo;
fi
fi
echo "Updating nightly base";
echo "base-commit=$NEW_BASE_COMMIT" >> "$GITHUB_OUTPUT"
- name: Install Rust toolchain
if: ${{ steps.choose-base.outputs.base-commit != 'skip' }}
uses: dtolnay/rust-toolchain@stable
with:
components: cargo
- name: Add -nightly+(date)-(commit ID) prefix to crate versions
id: set-nightly-version
if: ${{ steps.choose-base.outputs.base-commit != 'skip' }}
run: |
echo Force updating nightly branch to point to base branch
git branch -f nightly
export NIGHTLY_SUFFIX=$(echo -nightly+`date +%F`-`git rev-parse --short HEAD`)
echo Will add nightly suffix $NIGHTLY_SUFFIX
sed -i "s/^version = \"\\(.*\\)\"/version = \"\\1$NIGHTLY_SUFFIX\"/" sdk/Cargo.toml
cargo update -w
git add -f Cargo.lock
echo
echo Proposed changes:
git status
git diff
- name: Commit Cargo.toml and Cargo.lock
uses: stefanzweifel/git-auto-commit-action@v5
id: commit
if: ${{ steps.choose-base.outputs.base-commit != 'skip' }}
with:
branch: nightly
push_options: '--force'
commit_message: Prepare nightly release
commit_user_name: Adobe CAI Team
commit_user_email: noreply@adobe.com
create_branch: true