Skip to content

Commit dfe78c7

Browse files
committed
Add crontab support for pre-release.yml
1 parent 898cfa2 commit dfe78c7

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

.github/workflows/pre-release.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
name: Pre Release
22

33
on:
4+
push:
5+
branches:
6+
- nightly # Just for test purpose only with the nightly repo
47
# This schedule will run only from the default branch
58
schedule:
69
- cron: '30 1 * * *' # run at 00:15 AM UTC
@@ -39,6 +42,21 @@ jobs:
3942
- name: Pre Release
4043
shell: nu {0}
4144
run: |
45+
const MAX_COUNT = 12
46+
const RELEASE_INTERVAL = 28
47+
const DATE_FORMAT = '%Y/%m/%d'
48+
const START_DATE = '2024/10/15'
49+
let releaseDays = 1..$MAX_COUNT | each {|it| ($START_DATE | into datetime) + ($'($RELEASE_INTERVAL * $it)day' | into duration) | format date $DATE_FORMAT }
50+
print $'Checking for the following release day:(char nl)'
51+
$env.config.table.mode = 'psql'
52+
$releaseDays | print
53+
let force = '${{ github.event.inputs.force }}' == 'true'
54+
# Do a pre release The day before offical release date
55+
let shouldRelease = ((date now) + 1day | format date $DATE_FORMAT) in $releaseDays
56+
if $force != true and (not $shouldRelease) {
57+
print 'No need to pre release. Bye...'; exit 0
58+
}
59+
if $force { print 'Force run is enabled. Doing a pre release now ...' }
4260
cd $env.GITHUB_WORKSPACE
4361
git checkout main
4462
# We can't push if no user name and email are configured
@@ -51,8 +69,9 @@ jobs:
5169
git reset --hard src/main
5270
git push origin main -f
5371
let version = open Cargo.toml | get package.version
54-
let tag_name = $'($version)-pre'
55-
if (git ls-remote --tags origin $tag_name | is-empty) {
56-
git tag -a $tag_name -m $'Pre release from Nushell main branch'
57-
git push origin --tags
58-
}
72+
let tag = $'($version)-pre'
73+
if $tag in (git tag | lines) { git tag -d $tag }
74+
git tag -a $tag -m $'Pre release from Nushell main branch'
75+
git push origin $tag --force
76+
print $'The tag (ansi p)($tag)(ansi reset) has been created and the release workflow has been triggered.'
77+
print $'Please check it at https://github.com/nushell/nightly/actions/workflows/release.yml'

0 commit comments

Comments
 (0)