-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR: Add CI workflow for package release on tag push (#195)
* Add CI workflow for pakcage release on tag push * Add scripts and handling of environment variables * Clean up yaml files * Update CI workflow to release with tags * Update MANIEST
- Loading branch information
Showing
11 changed files
with
179 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
# Standard library imports | ||
import os | ||
|
||
|
||
def create_npmrc(): | ||
""" | ||
Create NPM configuration file in user home directory to use authentication | ||
token from environment variables. | ||
""" | ||
fpath = os.path.expanduser("~/.npmrc") | ||
with open(fpath, "w") as fh: | ||
fh.write("//registry.npmjs.org/:_authToken=${NPM_TOKEN}") | ||
|
||
|
||
if __name__ == "__main__": | ||
create_npmrc() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env python | ||
# coding: utf-8 | ||
|
||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
# Standard library imports | ||
import os | ||
import subprocess | ||
|
||
# Constants | ||
HERE = os.path.abspath(os.path.dirname(__file__)) | ||
REPO_ROOT = os.path.dirname(os.path.dirname(HERE)) | ||
|
||
|
||
def parse_ref(current_ref): | ||
""" | ||
Extract version string from github reference string and create environment | ||
variable for use within the CI workflows. | ||
Parameters | ||
---------- | ||
current_ref: str | ||
The github reference string. | ||
""" | ||
if not current_ref.startswith("ref/tags/"): | ||
raise Exception(f"Invalid ref `{current_ref}`!") | ||
|
||
tag_name = current_ref.replace("ref/tags/", "") | ||
if not tag_name.startswith("v"): | ||
raise Exception(f"Invalid tag `{tag_name}`!") | ||
|
||
print(f"::set-env name=RELEASE_TAG::{tag_name}") | ||
|
||
|
||
if __name__ == "__main__": | ||
current_ref = os.environ.get("GITHUB_REF") | ||
parse_ref(current_ref) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: Create Release and publish package | ||
|
||
on: | ||
push: | ||
tags: | ||
- '**' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: '3.8' | ||
- name: Install dependencies | ||
run: | | ||
pip install --upgrade pip setuptools | ||
pip install bump2version check-manifest twine wheel | ||
- name: Build release | ||
run: | | ||
check-manifest -v | ||
python setup.py sdist bdist_wheel | ||
python -m twine check dist/* | ||
- name: Parse tag | ||
run: python .github/scripts/parse_ref.py | ||
- name: Create Release | ||
id: create_release | ||
uses: ncipollo/release-action@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag: ${{ env.RELEASE_TAG }} | ||
name: Release ${{ env.RELEASE_TAG }} | ||
artifacts: ${{ env.CURRENT_LOCALE_DIR }}/dist/* | ||
body: Release ${{ env.RELEASE_TAG }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Publish PyPI Package | ||
env: | ||
TWINE_USERNAME: __token__ | ||
TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} | ||
run: python -m twine upload dist/* | ||
- name: Create NPM configuration | ||
run: python .github/scripts/create_npmrc.py | ||
- name: Publish NPM Package | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npm publish |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ __pycache__ | |
*.bak | ||
.ipynb_checkpoints | ||
.tox | ||
.DS_Store | ||
**.DS_Store | ||
\#*# | ||
.#* | ||
.coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Make sure to update package.json, too! | ||
version_info = (5, 0, 9, 'dev') | ||
version_info = (5, 0, 9, 'beta0') | ||
__version__ = '.'.join(map(str, version_info)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters