Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add schedule trigger to build a nightly release a 22h30 every day #6626

Merged
merged 2 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .github/workflows/_parse_version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
required: true
type: string
description: The version to parse
commit_sha:
required: true
type: string
description: The commit SHA to use when checkout'ing the repository
default: ${{ github.sha }}
outputs:
full:
description: The full version
Expand Down Expand Up @@ -35,6 +40,9 @@ on:
no_local:
description: The full version without the local part
value: ${{ jobs.parse.outputs.no_local }}
commit_sha:
description: The commit SHA used to checkout the repository
value: ${{ inputs.commit_sha }}

jobs:
parse:
Expand All @@ -52,6 +60,8 @@ jobs:
no_local: ${{ steps.version.outputs.no_local }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin v4.1.1
with:
ref: ${{ inputs.commit_sha }}
timeout-minutes: 5

- name: Parse Version
Expand Down
53 changes: 53 additions & 0 deletions .github/workflows/_releaser_nightly_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Releaser nightly build

on:
pull_request:
paths:
- .github/workflows/_releaser_nightly_build.yml
workflow_call:
outputs:
commit_sha:
description: |
The commit sha of the nightly release branch/tag.
value: ${{ jobs.nightly-build.outputs.commit_sha }}
version_full:
description: |
The full version of the nightly release that was created.
value: ${{ jobs.nightly-build.outputs.version_full }}

jobs:
nightly-build:
name: 🌙 Nightly build
runs-on: ubuntu-22.04
outputs:
commit_sha: ${{ steps.commit.outputs.id }}
version_full: ${{ steps.version.outputs.full }}
permissions:
contents: write
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin v4.1.1
timeout-minutes: 5

- name: Configure git
run: |
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git config user.name 'github-actions[bot]'
timeout-minutes: 1

- name: Create nightly release
run: >-
PYTHONPATH=. python3
misc/releaser.py build --nightly --yes --no-gpg-sign
timeout-minutes: 2

- name: Get commit for nightly tag
id: commit
run: echo "id=$(git rev-parse nightly)" | tee -a $GITHUB_OUTPUT
timeout-minutes: 1

- name: Parse version
id: version
run: >-
PYTHONPATH=. python3
misc/releaser.py version | tee -a $GITHUB_OUTPUT
timeout-minutes: 1
10 changes: 10 additions & 0 deletions .github/workflows/package-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ on:
If not provided, the workflow will generate the patch by itself.
type: string
required: true
commit_sha:
required: true
type: string
description: The commit SHA to use when checkout'ing the repository
default: ${{ github.sha }}
workflow_dispatch:
inputs:
version:
Expand Down Expand Up @@ -46,6 +51,7 @@ jobs:
uses: ./.github/workflows/_parse_version.yml
with:
version: ${{ inputs.version }}
commit_sha: ${{ inputs.commit_sha }}

webapp:
needs: version
Expand All @@ -55,6 +61,8 @@ jobs:
name: ⚡ Package web app
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin v4.1.1
with:
ref: ${{ inputs.commit_sha }}
timeout-minutes: 5

- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin v4.0.2
Expand Down Expand Up @@ -133,6 +141,8 @@ jobs:
timeout-minutes: 60
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin v4.1.1
with:
ref: ${{ inputs.commit_sha }}
timeout-minutes: 5

- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # pin v4.0.2
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/package-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ on:
If not provided, the workflow will generate the patch by itself.
type: string
required: true

commit_sha:
required: true
type: string
description: The commit SHA to use when checkout'ing the repository
default: ${{ github.sha }}
# PS: If you trigger manually the packaging, take into account that it will use the workflow as defined in the main branch not in the target branch.
workflow_dispatch:
inputs:
Expand Down Expand Up @@ -50,6 +54,7 @@ jobs:
uses: ./.github/workflows/_parse_version.yml
with:
version: ${{ inputs.version }}
commit_sha: ${{ inputs.commit_sha }}

package-wheel:
needs: version
Expand All @@ -72,6 +77,8 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # pin v4.1.1
with:
ref: ${{ inputs.commit_sha }}
timeout-minutes: 5

- uses: ./.github/actions/setup-python-poetry
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/releaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ on:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
- nightly
schedule:
- cron: 30 22 * * * # At 22:30
permissions:
contents: write

Expand All @@ -19,36 +21,49 @@ concurrency:
cancel-in-progress: true

jobs:
scheduled-nightly-build:
if: github.event_name == 'schedule'
uses: ./.github/workflows/_releaser_nightly_build.yml

version:
needs: scheduled-nightly-build
# Always run the job if `scheduled-nightly-build` job is skipped otherwise only if `scheduled-nightly-build` job was successful.
if: github.event_name != 'schedule' && always() || success()
uses: ./.github/workflows/_parse_version.yml
with:
version: >-
${{
github.event_name == 'push' && github.ref_name ||
startsWith(github.ref, 'refs/tags/') && github.ref_name ||
(github.event_name == 'schedule' && needs.scheduled-nightly-build.outputs.version_full) ||
(startsWith(github.ref, 'refs/tags/') && github.ref_name != 'nightly' && github.ref_name) ||
''
}}
commit_sha: ${{ needs.scheduled-nightly-build.outputs.commit_sha || github.sha }}

package-parsec-server:
needs: version
if: needs.version.result == 'success' && always()
uses: ./.github/workflows/package-server.yml
with:
version: ${{ needs.version.outputs.full }}
version_patch_run_id: ${{ github.run_id }}
commit_sha: ${{ needs.version.outputs.commit_sha }}

package-parsec-client:
needs: version
if: needs.version.result == 'success' && always()
uses: ./.github/workflows/package-client.yml
with:
version: ${{ needs.version.outputs.full }}
version_patch_run_id: ${{ github.run_id }}
commit_sha: ${{ needs.version.outputs.commit_sha }}

releaser:
needs:
- version
- package-parsec-server
- package-parsec-client
name: 🚛 Releaser
if: join(needs.*.result, '-') == 'success-success-success' && always()
runs-on: ubuntu-22.04
steps:
- name: Download every artifact generated (and uploaded)
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ url = { version = "2.5.0", default-features = false }
uuid = { version = "1.7.0", default-features = false }
wasm-bindgen-futures = { version = "0.4.42", default-features = false }
wasm-bindgen-test = { version = "0.3.42", default-features = false }
wasm-bindgen = { version = "0.2.91", default-features = false }
wasm-bindgen = { version = "0.2.92", default-features = false }
web-sys = { version = "0.3.69", default-features = false }
widestring = { version = "1.0.2", default-features = false }
windows-sys = { version = "0.52.0", default-features = false }
Expand Down
38 changes: 25 additions & 13 deletions misc/releaser.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ def create_bump_commit_to_new_version(
current_version: Version,
newsfragments: list[Path],
files_to_commit: set[Path],
gpg_sign: bool,
) -> None:
commit_msg = f"Bump version {current_version} -> {new_version}"
print(f"Create commit {COLOR_GREEN}{commit_msg}{COLOR_END}")
Expand All @@ -518,39 +519,47 @@ def create_bump_commit_to_new_version(
run_git("rm", *fragments_paths)
# FIXME: the `releaser` steps in pre-commit is disable is `no-verify` still required ?
# Disable pre-commit hooks given this commit wouldn't pass `releaser check`
run_git("commit", f"--message={commit_msg}", "--no-verify", "--gpg-sign")
run_git(
"commit",
f"--message={commit_msg}",
"--no-verify",
"--gpg-sign" if gpg_sign else "--no-gpg-sign",
)


def create_tag_for_new_version(version: Version, tag: str, force: bool = False) -> None:
def create_tag_for_new_version(version: Version, tag: str, gpg_sign: bool, force: bool) -> None:
print(f"Create tag {COLOR_GREEN}{tag}{COLOR_END}")
run_git(
"tag",
*(["--force"] if force else []),
tag,
f"--message=Release version {version}",
"--annotate",
"--sign",
"--sign" if gpg_sign else "--no-sign",
)


def inspect_tag(tag: str, yes: bool) -> None:
def inspect_tag(tag: str, yes: bool, gpg_sign: bool) -> None:
print(f"Inspect tag {COLOR_GREEN}{tag}{COLOR_END}")

print(run_git("show", tag, "--show-signature", "--quiet"))
print(run_git("tag", "--verify", tag))
if gpg_sign:
print(run_git("show", tag, "--show-signature", "--quiet"))
print(run_git("tag", "--verify", tag))

if not yes:
input("Check if the generated git tag is okay... (press any key to continue)")


def create_bump_commit_to_dev_version(version: Version, license_eol_date: datetime) -> None:
def create_bump_commit_to_dev_version(
version: Version, license_eol_date: datetime, gpg_sign: bool
) -> None:
dev_version = version.evolve(local="dev")
update_license_file(dev_version, license_eol_date)
updated_files = update_version_files(dev_version)
create_bump_commit_to_new_version(dev_version, version, [], updated_files)
create_bump_commit_to_new_version(dev_version, version, [], updated_files, gpg_sign)


def push_release(tag: str, release_branch: str, yes: bool, force_push: bool = False) -> None:
def push_release(tag: str, release_branch: str, yes: bool, force_push: bool) -> None:
print("Pushing changes to remote...")

if not yes:
Expand Down Expand Up @@ -726,16 +735,16 @@ def build_main(args: argparse.Namespace) -> None:
update_history_changelog(newsfragments, release_version, yes, release_date)

create_bump_commit_to_new_version(
release_version, current_version, newsfragments, updated_files
release_version, current_version, newsfragments, updated_files, gpg_sign=args.gpg_sign
)

create_tag_for_new_version(release_version, tag, force=args.nightly)
create_tag_for_new_version(release_version, tag, gpg_sign=args.gpg_sign, force=args.nightly)

inspect_tag(tag, yes)
inspect_tag(tag, yes, gpg_sign=args.gpg_sign)

# No need to create a dev version for a nightly release.
if not args.nightly:
create_bump_commit_to_dev_version(release_version, license_eol_date)
create_bump_commit_to_dev_version(release_version, license_eol_date, gpg_sign=args.gpg_sign)

push_release(tag, release_branch, yes, force_push=args.nightly)

Expand Down Expand Up @@ -900,6 +909,9 @@ def cli(description: str) -> argparse.Namespace:
"--nightly", action="store_true", help="Prepare for a new nightly release"
)
build.add_argument("-y", "--yes", help="Reply `yes` to asked question", action="store_true")
build.add_argument(
"--no-gpg-sign", dest="gpg_sign", action="store_false", help="Do not sign the commit or tag"
)
build.add_argument(
"--base",
dest="base_ref",
Expand Down
Loading