Skip to content
This repository has been archived by the owner on Dec 16, 2022. It is now read-only.

Commit

Permalink
add nightly releases (#81)
Browse files Browse the repository at this point in the history
  • Loading branch information
epwalsh authored Jun 23, 2020
1 parent 935a2a8 commit d210c2f
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
42 changes: 32 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: PyPI Release
on:
release:
types: [published]
schedule:
# Nightly releases.
# These must run after the AllenNLP nightly releases, since the corresponding AllenNLP
# release will be a dependency.
- cron: '48 12 * * 1,2,3,4,5' # early morning (12:48 UTC / 5:48 AM PDT) Monday - Friday

jobs:
build:
Expand All @@ -20,6 +25,31 @@ jobs:
with:
python-version: ${{ matrix.python }}

- name: Check and set nightly version
if: github.event_name == 'schedule'
run: |
# The get_version.py script requires the 'requests' package.
pip install requests
LATEST=$(scripts/get_version.py latest)
CURRENT=$(scripts/get_version.py current)
# Verify that current version is ahead of the last release.
if [ "$CURRENT" == "$LATEST" ]; then
echo "Current version needs to be ahead of latest release in order to build nightly release";
exit 1;
fi
echo ::set-env name=ALLENNLP_MODELS_VERSION_SUFFIX::.dev$(date -u +%Y%m%d)
- name: Check version and release tag match
if: github.event_name == 'release'
run: |
# Remove 'refs/tags/' to get the actual tag from the release.
TAG=${GITHUB_REF#refs/tags/};
VERSION=$(scripts/get_version.py current)
if [ "$TAG" != "$VERSION" ]; then
echo "Bad tag or version. Tag $TAG does not match $VERSION";
exit 1;
fi
- name: Set AllenNLP version override
run: |
VERSION=$(./scripts/get_version.py current --minimal)
Expand All @@ -33,16 +63,6 @@ jobs:
pip install -e .
pip install -r dev-requirements.txt
- name: Check version and release tag match
run: |
# Remove 'refs/tags/' to get the actual tag from the release.
TAG=${GITHUB_REF#refs/tags/};
VERSION=$(scripts/get_version.py current)
if [ "$TAG" != "$VERSION" ]; then
echo "Bad tag or version. Tag $TAG does not match $VERSION";
exit 1;
fi
- name: Show pip freeze
run: |
pip freeze
Expand Down Expand Up @@ -121,6 +141,8 @@ jobs:
docker:
name: Docker
needs: [build] # needs the package artifact created from 'build_package' job.
# Don't run for nightly releases.
if: github.event_name != 'schedule'
runs-on: ubuntu-latest

steps:
Expand Down
11 changes: 8 additions & 3 deletions allennlp_models/version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import os

_MAJOR = "1"
_MINOR = "0"
_REVISION = "0"
_MINOR = "1"
_PATCH = "0rc1"
# This is mainly for nightly builds which have the suffix ".dev$DATE". See
# https://semver.org/#is-v123-a-semantic-version for the semantics.
_SUFFIX = os.environ.get("ALLENNLP_MODELS_VERSION_SUFFIX", "")

VERSION_SHORT = "{0}.{1}".format(_MAJOR, _MINOR)
VERSION = "{0}.{1}.{2}".format(_MAJOR, _MINOR, _REVISION)
VERSION = "{0}.{1}.{2}{3}".format(_MAJOR, _MINOR, _PATCH, _SUFFIX)
18 changes: 11 additions & 7 deletions scripts/get_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@ def parse_args():
return parser.parse_args()


def get_current_version(minimal: bool = False) -> str:
def post_process(version: str, minimal: bool = False):
if version.startswith("v"):
return version if not minimal else version[1:]
return version if minimal else f"v{version}"


def get_current_version() -> str:
VERSION: Dict[str, str] = {}
with open("allennlp_models/version.py", "r") as version_file:
exec(version_file.read(), VERSION)
if minimal:
return VERSION["VERSION"]
return "v" + VERSION["VERSION"]
return VERSION["VERSION"]


def get_latest_version() -> str:
Expand All @@ -39,11 +43,11 @@ def get_stable_version() -> str:
def main() -> None:
opts = parse_args()
if opts.version_type == "stable":
print(get_stable_version(minimal=opts.minimal))
print(post_process(get_stable_version(), opts.minimal))
elif opts.version_type == "latest":
print(get_latest_version(minimal=opts.minimal))
print(post_process(get_latest_version(), opts.minimal))
elif opts.version_type == "current":
print(get_current_version(minimal=opts.minimal))
print(post_process(get_current_version(), opts.minimal))
else:
raise NotImplementedError

Expand Down

0 comments on commit d210c2f

Please sign in to comment.