Skip to content

Commit

Permalink
Adds Github Actions for release automation. (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheqianh committed May 6, 2022
1 parent 5d117f7 commit e3a2fff
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.6']
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.6', 'pypy-3.7', 'pypy-3.8']
steps:
- uses: actions/checkout@v2
- name: Set up Python
Expand Down
173 changes: 173 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
name: Ion Python Release

on:
release:
types: [ created ]

jobs:
test:
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.6', '3.7', '3.8', '3.9', '3.10', 'pypy-3.6', 'pypy-3.7', 'pypy-3.8' ]
steps:
- uses: actions/checkout@v3
- name: Set up python
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Create a virtual environment
run: git submodule init && git submodule update && python3 -m venv ./venv && . venv/bin/activate
- run: pip install -r requirements.txt
- run: pip install -e .
- run: py.test

source-distribution:
if: startsWith(github.ref, 'refs/tags/')
name: Source distribution
runs-on: ubuntu-latest
needs: [test]
strategy:
matrix:
python-version: [ '3.10' ]
steps:
- uses: actions/checkout@v3

- name: Build sdist
run: python3 setup.py sdist

- name: Upload source to Github
uses: actions/upload-artifact@v2
with:
name: source
path: ./dist/amazon.ion-*.tar.gz

- uses: aws-actions/configure-aws-credentials@v1
with:
role-skip-session-tagging: true
aws-region: us-west-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
role-duration-seconds: 900

- name: Upload source to s3
run: |
zip ion-python-source ./dist/amazon.ion-*.tar.gz
aws s3 mv ion-python-source.zip ${{ secrets.AWS_SOURCE_BUCKET_URL }} --acl bucket-owner-full-control
- name: Install the released source from PYPI
run: |
sleep 300s
for (( i=0; i<3; i++ ))
do
v=""
if ! (pip install --no-binary :all: amazon.ion==${GITHUB_REF##*/v}) then
echo "Unable to install the desired version"
sleep 120s
continue
fi
v=$( pip show amazon.ion | grep Version )
break
done
if [[ $v != "Version: ${GITHUB_REF##*/v}" ]]
then
echo "Exiting because unable to install the new version from PYPI"
exit 1
fi
build-wheels:
name: Build wheels on ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/')
needs: [test]
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
python-version: [ '3.10']
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- uses: actions/checkout@v3

- name: Set up pip and setuptools
run: |
pip3 install -U pip
pip3 install -U setuptools
- name: Set up QEMU
if: runner.os == 'Linux'
uses: docker/setup-qemu-action@v1
with:
platforms: all

- name: Install cibuildwheel
run: python3 -m pip install cibuildwheel==2.4.0

- name: Build wheels
run: python3 -m cibuildwheel --output-dir wheelhouse
env:
CIBW_SKIP: "pp* *-win32"
CIBW_ARCHS_WINDOWS: "auto"
CIBW_ARCHS_LINUX: "auto aarch64"
CIBW_ARCHS_MACOS: "x86_64"

- name: Upload wheels to Github
uses: actions/upload-artifact@v2
with:
name: wheels
path: ./wheelhouse/*.whl

upload-wheels:
name: Upload wheels to S3
runs-on: [ubuntu-latest]
needs: [build-wheels]
steps:
- uses: actions/download-artifact@v2
with:
name: wheels

- uses: aws-actions/configure-aws-credentials@v1
with:
role-skip-session-tagging: true
aws-region: us-west-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-external-id: ${{ secrets.AWS_ROLE_EXTERNAL_ID }}
role-duration-seconds: 900

- name: Upload wheels to s3
run: |
zip ion-python-wheels ./*.whl
aws s3 mv ion-python-wheels.zip ${{ secrets.AWS_WHEELS_BUCKET_URL }} --acl bucket-owner-full-control
- name: Install the released wheels from PYPI
run: |
sleep 300s
for (( i=0; i<3; i++ ))
do
v=""
if ! (pip install --only-binary :all: amazon.ion==${GITHUB_REF##*/v}) then
echo "Unable to install the desired version"
sleep 120s
continue
fi
v=$( pip show amazon.ion | grep Version )
break
done
if [[ $v != "Version: ${GITHUB_REF##*/v}" ]]
then
echo "Exiting because unable to install the new version from PYPI"
exit 1
fi
3 changes: 2 additions & 1 deletion install.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def _move_ionc():

def _build_ionc_win():
# check_call('cmake -G \"Visual Studio 15 2017 Win64\"')
check_call('cmake -G \"Visual Studio 16 2019\"')
# check_call('cmake -G \"Visual Studio 16 2019\"')
check_call('cmake -G \"Visual Studio 17 2022\"')
check_call('cmake --build . --config Release')


Expand Down
2 changes: 1 addition & 1 deletion ion-c
Submodule ion-c updated from 9310a9 to 2671a0
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ six==1.16.0
toml==0.10.2
tox==3.23.1
virtualenv==20.4.7
setuptools==60.5.0
setuptools<=60.5.0

0 comments on commit e3a2fff

Please sign in to comment.