Skip to content

Commit f938641

Browse files
authored
Merge pull request rust-lang#23108 from lnicola/release-suffix
internal: Support multiple stable releases in one day
2 parents 513f60b + 157f50e commit f938641

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

.github/workflows/release.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,17 +214,29 @@ jobs:
214214
with:
215215
node-version: 22
216216

217-
- run: echo "TAG=$(date --iso -u)" >> $GITHUB_ENV
218-
if: github.ref == 'refs/heads/release'
219-
- run: echo "TAG=nightly" >> $GITHUB_ENV
220-
if: github.ref != 'refs/heads/release'
221-
- run: 'echo "TAG: $TAG"'
222-
223217
- name: Checkout repository
224218
uses: actions/checkout@v6
225219
with:
226220
fetch-depth: ${{ env.FETCH_DEPTH }}
227221

222+
- name: Set release tag
223+
run: |
224+
if [ "${{ github.ref }}" = "refs/heads/release" ]; then
225+
git fetch --tags
226+
today=$(date --iso -u)
227+
last_tag=$(git tag -l "${today}*" | sort -V | tail -n1)
228+
if [ -n "$last_tag" ]; then
229+
last_v=$(echo "$last_tag" | grep -oP '(?<=\.)\d+' || echo 0)
230+
new_v=$(($last_v + 1))
231+
tag="${today}.${new_v}"
232+
else
233+
tag="$today"
234+
fi
235+
echo "TAG=$tag" >> $GITHUB_ENV
236+
else
237+
echo "TAG=nightly" >> $GITHUB_ENV
238+
fi
239+
228240
- run: echo "HEAD_SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV
229241
- run: 'echo "HEAD_SHA: $HEAD_SHA"'
230242

xtask/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,5 +91,8 @@ fn date_iso(sh: &Shell) -> anyhow::Result<String> {
9191
}
9292

9393
fn is_release_tag(tag: &str) -> bool {
94-
tag.len() == "2020-02-24".len() && tag.starts_with(|c: char| c.is_ascii_digit())
94+
tag.len() >= 10
95+
&& tag.starts_with(|c: char| c.is_ascii_digit())
96+
&& tag.as_bytes()[4] == b'-'
97+
&& tag.as_bytes()[7] == b'-'
9598
}

0 commit comments

Comments
 (0)