Skip to content

Commit

Permalink
Add crontab support for pre-release.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
hustcer committed Oct 24, 2024
1 parent 898cfa2 commit dfe78c7
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions .github/workflows/pre-release.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
name: Pre Release

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

0 comments on commit dfe78c7

Please sign in to comment.