Skip to content
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
15 changes: 15 additions & 0 deletions release/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# VRL release steps

1. Create a release PR

```shell
python3 create_release_pull_request.py <version>
```

2. Wait for the PR to be merged

3. Run the publish script

```shell
python3 publish.py
```
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env python3
import argparse
import os
import subprocess
Expand All @@ -6,6 +7,8 @@

import semver

from utils.validate_version import assert_version_is_not_published

SCRIPTS_DIR = os.path.dirname(abspath(getsourcefile(lambda: 0)))
REPO_ROOT_DIR = os.path.dirname(SCRIPTS_DIR)
CHANGELOG_DIR = os.path.join(REPO_ROOT_DIR, "changelog.d")
Expand Down Expand Up @@ -50,6 +53,7 @@ def validate_version(version):
print(f"Invalid version: {version}. Please provide a valid SemVer string.")
exit(1)

assert_version_is_not_published(version)

def generate_changelog():
print("Generating changelog...")
Expand Down Expand Up @@ -95,6 +99,7 @@ def main():
create_branch(branch_name, dry_run)
overwrite_version(new_version)
generate_changelog()
subprocess.run(["git", "push"], check=True, cwd=REPO_ROOT_DIR)
create_pull_request(branch_name, new_version, dry_run)

if dry_run:
Expand Down
29 changes: 6 additions & 23 deletions scripts/publish.py → release/publish.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,17 @@
#!/usr/bin/env python3
import os
import subprocess
from inspect import getsourcefile
from os.path import abspath

import requests
import toml

from utils.validate_version import assert_version_is_not_published

SCRIPTS_DIR = os.path.dirname(abspath(getsourcefile(lambda: 0)))
REPO_ROOT_DIR = os.path.dirname(SCRIPTS_DIR)
CHANGELOG_DIR = os.path.join(REPO_ROOT_DIR, "changelog.d")

def get_crate_versions(crate_name):
# crates.io returns a 403 now for the default requests user-agent
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'}

response = requests.get(f"https://crates.io/api/v1/crates/{crate_name}", headers=headers)
if response.status_code != 200:
raise Exception(f"Error fetching crate info: {response.status_code}")
data = response.json()
return [version["num"] for version in data["versions"]]


def read_version_from_cargo_toml(filepath):
with open(filepath, "r") as file:
Expand All @@ -34,7 +26,8 @@ def publish_vrl(version):

tag_name = f"v{version}"
tag_message = f"Release {version}"
subprocess.run(["git", "tag", "-a", tag_name, "-m", tag_message], check=True, cwd=REPO_ROOT_DIR)
subprocess.run(["git", "tag", "-a", tag_name, "-m", tag_message], check=True,
cwd=REPO_ROOT_DIR)
subprocess.run(["git", "push", "origin", tag_name], check=True, cwd=REPO_ROOT_DIR)
print(f"Tagged version.")
except subprocess.CalledProcessError as e:
Expand All @@ -43,21 +36,11 @@ def publish_vrl(version):

def assert_no_changelog_fragments():
entries = os.listdir(CHANGELOG_DIR)
error = f"{CHANGELOG_DIR} should only contain a README.md file. Did you run ./scripts/generate_release_changelog.sh?"
error = f"{CHANGELOG_DIR} should only contain a README.md file. Did you run ../scripts/generate_release_changelog.sh?"
assert len(entries) == 1, error
assert entries[0] == "README.md", error


def assert_version_is_not_published(current_version):
crate_name = "vrl"
versions = get_crate_versions(crate_name)
print(f"Available versions for {crate_name}: {versions}")

if current_version in versions:
print(f"The version {current_version} is already published. Please update the version and try again.")
exit(1)


def main():
assert_no_changelog_fragments()

Expand Down
2 changes: 2 additions & 0 deletions release/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
requests
semver
Empty file added release/utils/__init__.py
Empty file.
24 changes: 24 additions & 0 deletions release/utils/validate_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import requests


def get_crate_versions(crate_name):
# crates.io returns a 403 now for the default requests user-agent
headers = {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36'}

response = requests.get(f"https://crates.io/api/v1/crates/{crate_name}", headers=headers)
if response.status_code != 200:
raise Exception(f"Error fetching crate info: {response.status_code}")
data = response.json()
return [version["num"] for version in data["versions"]]


def assert_version_is_not_published(current_version):
crate_name = "vrl"
versions = get_crate_versions(crate_name)
print(f"Available versions for {crate_name}: {versions}")

if current_version in versions:
print(
f"The version {current_version} is already published. Please update the version and try again.")
exit(1)
Loading