-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
--- | ||
name: Deploy Pre-Release Artifacts | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
env: | ||
LANG: en_US.utf-8 | ||
LC_ALL: en_US.utf-8 | ||
PYTHON_VERSION: '3.8' | ||
PROJECT_NAME: test-release-actions | ||
RUNS_ON: ubuntu-20.04 | ||
|
||
jobs: | ||
|
||
bump_version: | ||
environment: test_env | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event." | ||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!" | ||
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}." | ||
|
||
#---------------------------------------------- | ||
# check-out repo and set-up python | ||
#---------------------------------------------- | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Set up Python ${{ env.PYTHON_VERSION }} | ||
id: setup-python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ env.PYTHON_VERSION }} | ||
|
||
#---------------------------------------------- | ||
# ----- install & configure poetry ----- | ||
#---------------------------------------------- | ||
- name: Install Poetry | ||
uses: snok/install-poetry@v1 | ||
with: | ||
version: 1.2.0b2 | ||
virtualenvs-create: true | ||
virtualenvs-in-project: true | ||
installer-parallel: true | ||
|
||
#---------------------------------------------- | ||
# load cached venv if cache exists | ||
#---------------------------------------------- | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/[email protected] | ||
with: | ||
path: .venv | ||
key: venv-${{ runner.os }}-${{ steps.setup-python.outputs.python-version }}-${{ hashFiles('**/poetry.lock') }} | ||
|
||
#---------------------------------------------- | ||
# install dependencies if cache does not exist | ||
#---------------------------------------------- | ||
- name: Install dependencies | ||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' | ||
run: poetry install --no-interaction --no-root | ||
|
||
#---------------------------------------------- | ||
# install your root project, if required | ||
#---------------------------------------------- | ||
- name: Install library | ||
run: | | ||
poetry install --no-interaction | ||
#---------------------------------------------- | ||
# bump version number for patch | ||
#---------------------------------------------- | ||
- name: Bump Version | ||
run: | | ||
# current_tag is the last tagged relese in the repository. From there | ||
# we need to remove the v from the begining of the tag. | ||
if ! $(git tag -l "v*" = ''); then | ||
# uses -V which is version sort to keep it monotonically increasing. | ||
current_tag=$(git tag -l "v*" | grep --invert-match '-' | sort --reverse -V | sed -n 1p) | ||
else | ||
current_tag=v0.0.1 | ||
fi | ||
current_tag=${current_tag#?} | ||
# current_tag is now the version we want to set our poetry version so | ||
# that we can bump the version | ||
poetry version ${current_tag} | ||
poetry version prerelease --no-interaction | ||
NEW_TAG=v$(poetry version --short) | ||
# Finally because we want to be able to use the variable in later | ||
# steps we set a NEW_TAG environmental variable | ||
echo "NEW_TAG=$(echo ${NEW_TAG})" >> $GITHUB_ENV | ||
#--------------------------------------------------------------- | ||
# create build artifacts to be included as part of release | ||
#--------------------------------------------------------------- | ||
- name: Create build artifacts | ||
run: | | ||
poetry build -vvv | ||
- uses: ncipollo/release-action@v1 | ||
with: | ||
artifacts: "dist/*.gz,dist/*.whl" | ||
artifactErrorsFailBuild: true | ||
generateReleaseNotes: true | ||
commit: ${{ github.ref }} | ||
prerelease: true | ||
tag: ${{ env.NEW_TAG }} | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish pre-release to pypi | ||
if: github.repository == 'GRIDAPPSD/gridappsd-2030_5' | ||
run: | | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | ||
poetry publish |