Skip to content

Commit

Permalink
Merge pull request #96 from dwhswenson/vendor-template
Browse files Browse the repository at this point in the history
Vendored actions are now templates
  • Loading branch information
dwhswenson authored Jul 6, 2021
2 parents c610c9a + ca32d14 commit 5c11d9b
Show file tree
Hide file tree
Showing 10 changed files with 56 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/autorelease-default-env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
INSTALL_AUTORELEASE="python -m pip install autorelease==0.3.0"
# Vendored from Autorelease 0.3.1
# Update by updating Autorelease and running `autorelease vendor actions`
INSTALL_AUTORELEASE="python -m pip install autorelease==0.3.1"
if [ -f autorelease-env.sh ]; then
source autorelease-env.sh
fi
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/autorelease-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Autorelease
# Vendored from Autorelease 0.3.1
# Update by updating Autorelease and running `autorelease vendor actions`
name: "Autorelease Deploy"
on:
release:
types: [published]
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/autorelease-gh-rel.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Autorelease
# Vendored from Autorelease 0.3.1
# Update by updating Autorelease and running `autorelease vendor actions`
name: "Autorelease Release"
on:
push:
branches:
# TODO: this should come from yaml conf
- stable

jobs:
Expand Down Expand Up @@ -31,3 +34,4 @@ jobs:
autorelease-release --project $PROJECT --version $VERSION --token $AUTORELEASE_TOKEN
env:
AUTORELEASE_TOKEN: ${{ secrets.AUTORELEASE_TOKEN }}
name: "Cut release"
7 changes: 4 additions & 3 deletions .github/workflows/autorelease-prep.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# File vencdored from Autorelease; specific version information should be in
# the INSTALL_AUTORELEASE variable in autorelease-default-env.sh
name: "Autorelease"
# Vendored from Autorelease 0.3.1
# Update by updating Autorelease and running `autorelease vendor actions`
name: "Autorelease testpypi"
on:
pull_request:
branches:
# TODO: this should come from yaml conf
- stable

defaults:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: "Unit tests"
on:
pull_request:
branches:
- master
- main
- stable
push:
branches:
- master
- main
tags:
- "v*"
schedule:
Expand Down
4 changes: 3 additions & 1 deletion autorelease/gh_actions_stages/autorelease-default-env.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
INSTALL_AUTORELEASE="python -m pip install autorelease==0.3.0"
# Vendored from Autorelease $VERSION
# Update by updating Autorelease and running `autorelease vendor actions`
INSTALL_AUTORELEASE="python -m pip install autorelease==$VERSION"
if [ -f autorelease-env.sh ]; then
source autorelease-env.sh
fi
Expand Down
10 changes: 6 additions & 4 deletions autorelease/gh_actions_stages/autorelease-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
name: Autorelease
# Vendored from Autorelease $VERSION
# Update by updating Autorelease and running `autorelease vendor actions`
name: "Autorelease Deploy"
on:
release:
types: [published]
Expand All @@ -15,12 +17,12 @@ jobs:
- run: | # TODO: move this to an action
source ./.github/workflows/autorelease-default-env.sh
if [ -f "autorelease-env.sh" ]; then
cat autorelease-env.sh >> $GITHUB_ENV
cat autorelease-env.sh >> $$GITHUB_ENV
fi
if [ -f "./.autorelease/install-autorelease" ]; then
source ./.autorelease/install-autorelease
else
eval $INSTALL_AUTORELEASE
eval $$INSTALL_AUTORELEASE
fi
name: "Install autorelease"
- run: |
Expand All @@ -32,6 +34,6 @@ jobs:
name: "Build and check package"
- uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}
password: $${{ secrets.pypi_password }}
name: "Deploy to pypi"

16 changes: 10 additions & 6 deletions autorelease/gh_actions_stages/autorelease-gh-rel.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
name: Autorelease
# Vendored from Autorelease $VERSION
# Update by updating Autorelease and running `autorelease vendor actions`
name: "Autorelease Release"
on:
push:
branches:
# TODO: this should come from yaml conf
- stable

jobs:
Expand All @@ -16,18 +19,19 @@ jobs:
- run: | # TODO: move this to an action
source ./.github/workflows/autorelease-default-env.sh
if [ -f "autorelease-env.sh" ]; then
cat autorelease-env.sh >> $GITHUB_ENV
cat autorelease-env.sh >> $$GITHUB_ENV
fi
if [ -f "./.autorelease/install-autorelease" ]; then
source ./.autorelease/install-autorelease
else
eval $INSTALL_AUTORELEASE
eval $$INSTALL_AUTORELEASE
fi
name: "Install autorelease"
- run: |
VERSION=`python setup.py --version`
PROJECT=`python setup.py --name`
echo $PROJECT $VERSION
autorelease-release --project $PROJECT --version $VERSION --token $AUTORELEASE_TOKEN
echo $$PROJECT $$VERSION
autorelease-release --project $$PROJECT --version $$VERSION --token $$AUTORELEASE_TOKEN
env:
AUTORELEASE_TOKEN: ${{ secrets.AUTORELEASE_TOKEN }}
AUTORELEASE_TOKEN: $${{ secrets.AUTORELEASE_TOKEN }}
name: "Cut release"
19 changes: 10 additions & 9 deletions autorelease/gh_actions_stages/autorelease-prep.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# File vencdored from Autorelease; specific version information should be in
# the INSTALL_AUTORELEASE variable in autorelease-default-env.sh
name: "Autorelease"
# Vendored from Autorelease $VERSION
# Update by updating Autorelease and running `autorelease vendor actions`
name: "Autorelease testpypi"
on:
pull_request:
branches:
# TODO: this should come from yaml conf
- stable

defaults:
Expand All @@ -22,12 +23,12 @@ jobs:
- run: | # TODO: move this to an action
source ./.github/workflows/autorelease-default-env.sh
if [ -f "autorelease-env.sh" ]; then
cat autorelease-env.sh >> $GITHUB_ENV
cat autorelease-env.sh >> $$GITHUB_ENV
fi
if [ -f "./.autorelease/install-autorelease" ]; then
source ./.autorelease/install-autorelease
else
eval $INSTALL_AUTORELEASE
eval $$INSTALL_AUTORELEASE
fi
name: "Install autorelease"
- run: |
Expand All @@ -43,7 +44,7 @@ jobs:
name: "Build and check package"
- uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.testpypi_password }}
password: $${{ secrets.testpypi_password }}
repository_url: https://test.pypi.org/legacy/
name: "Deploy to testpypi"
test_testpypi:
Expand All @@ -58,19 +59,19 @@ jobs:
- run: | # TODO: move this to an action
source ./.github/workflows/autorelease-default-env.sh
if [ -f "autorelease-env.sh" ]; then
cat autorelease-env.sh >> $GITHUB_ENV
cat autorelease-env.sh >> $$GITHUB_ENV
fi
if [ -f "./.autorelease/install-autorelease" ]; then
source ./.autorelease/install-autorelease
else
eval $INSTALL_AUTORELEASE
eval $$INSTALL_AUTORELEASE
fi
name: "Install autorelease"
- name: "Install testpypi version"
run: install-testpypi
- name: "Test testpypi version"
run: |
if [ -f "autorelease-env.sh" ]; then
cat autorelease-env.sh >> $GITHUB_ENV
cat autorelease-env.sh >> $$GITHUB_ENV
fi
test-testpypi
15 changes: 10 additions & 5 deletions autorelease/scripts/vendor.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import pkg_resources
import string
import pathlib
import shutil

import click
import pkg_resources
from packaging.version import Version
import autorelease

def vendor(resources, base_path, relative_target_dir):
for resource in resources:
Expand All @@ -12,7 +12,12 @@ def vendor(resources, base_path, relative_target_dir):
target_dir.mkdir(parents=True, exist_ok=True)
target_loc = base_path / relative_target_dir / name
# print(f"cp {orig_loc} {target_loc}")
shutil.copy(orig_loc, target_loc)
with open(orig_loc, mode='r') as rfile:
template = string.Template(rfile.read())

version = Version(autorelease.version.version).base_version
with open(target_loc, mode='w') as wfile:
wfile.write(template.substitute(VERSION=version))

def vendor_actions(base_path):
resources = ['autorelease-default-env.sh', 'autorelease-prep.yml',
Expand Down

0 comments on commit 5c11d9b

Please sign in to comment.