Skip to content

Commit

Permalink
Merge pull request #3 from niaid/GHAPublishPythonPackage
Browse files Browse the repository at this point in the history
Add Github Actions to package and publish
  • Loading branch information
blowekamp authored Mar 30, 2021
2 parents cac6dba + 2adefad commit a5d7261
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 2 deletions.
63 changes: 61 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ jobs:
run: |
trufflehog3 -v -c trufflehog3.yml . && echo "tufflehog3 OK"
test:

test_package:
needs: linting_test
runs-on: ubuntu-latest
strategy:
matrix:
Expand Down Expand Up @@ -74,3 +74,62 @@ jobs:
path: junit/test-results-${{ matrix.python-version }}.xml
# Use always() to always run this step to publish test results when there are test failures
if: ${{ always() }}
- name: Build package
run: |
python setup.py sdist bdist_wheel
ls -la dist
- name: Upload package
if: github.event_name == 'push'
uses: actions/upload-artifact@v1
with:
name: python-packages
path: dist

github_publish:
if: startsWith(github.ref, 'refs/tags/v')
needs: test_package
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
id: download
with:
name: python-packages
- name: Extract Python Packages
id: files
run: |
cd ${{steps.download.outputs.download-path}}
echo ::set-output name=file1::$(ls tomojs-pytools*any.whl)
echo ::set-output name=file2::$(ls tomojs-pytools*.tar.gz)
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset Wheel
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
# This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include
# an `upload_url`. See this blog post for more info:
# https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ${{steps.download.outputs.download-path}}/${{steps.files.outputs.file1}}
asset_name: ${{steps.files.outputs.file1}}
asset_content_type: application/octet-stream
- name: Upload Release Asset Source
if: startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
with:
upload_url: ${{steps.create_release.outputs.upload_url}}
asset_path: ${{steps.download.outputs.download-path}}/${{steps.files.outputs.file2}}
asset_name: ${{steps.files.outputs.file2}}
asset_content_type: application/octet-stream
1 change: 1 addition & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ pytest>=6.0
setuptools_scm
flake8
black
wheel
-rrequirements.txt

0 comments on commit a5d7261

Please sign in to comment.