|
| 1 | +name: Generate release (Pypi, tag, & GitHub Release) |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: [ master, main ] |
| 5 | + |
| 6 | +jobs: |
| 7 | + deploy: |
| 8 | + runs-on: ubuntu-latest |
| 9 | + |
| 10 | + steps: |
| 11 | + - name: Checkout repository |
| 12 | + uses: actions/checkout@main |
| 13 | + |
| 14 | + - name: Set up MPI |
| 15 | + uses: mpi4py/setup-mpi@master |
| 16 | + |
| 17 | + - name: Set up Python |
| 18 | + uses: actions/setup-python@main |
| 19 | + with: |
| 20 | + python-version: '3.10' |
| 21 | + |
| 22 | + - name: Install dependencies |
| 23 | + run: | |
| 24 | + pip install setuptools wheel twine |
| 25 | + pip install -r requirements.txt |
| 26 | + |
| 27 | + - name: Get tag name |
| 28 | + id: variables |
| 29 | + env: |
| 30 | + FOLDER_WITH_VERSION: ${{ vars.FOLDER_WITH_VERSION }} |
| 31 | + run: | |
| 32 | + VERSION=$(python -c "import $FOLDER_WITH_VERSION; print('VERSION', 'v'+$FOLDER_WITH_VERSION.__version__)" | grep VERSION | sed "s/VERSION //g") || (echo "Could not import version, check that variables are correctly set!" && exit 1) |
| 33 | + echo "TAG_NAME=${VERSION#v}" >> $GITHUB_OUTPUT |
| 34 | + echo "TAG NAME (must not contain version prefix): ${VERSION#v}" |
| 35 | + |
| 36 | + - name: Build and publish |
| 37 | + env: |
| 38 | + TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} |
| 39 | + TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} |
| 40 | + run: | |
| 41 | + python setup.py sdist |
| 42 | + twine upload dist/* -c "${{ secrets.PYPI_COMMENT }}" |
| 43 | + |
| 44 | + - name: Generate tag |
| 45 | + id: tag_version |
| 46 | + uses: mathieudutour/github-tag-action@v6.2 |
| 47 | + with: |
| 48 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 49 | + custom_tag: ${{ steps.variables.outputs.TAG_NAME }} |
| 50 | + |
| 51 | + - name: Create a GitHub release |
| 52 | + uses: ncipollo/release-action@main |
| 53 | + with: |
| 54 | + tag: ${{ steps.tag_version.outputs.new_tag }} |
| 55 | + name: ${{ steps.variables.outputs.TAG_NAME }} |
0 commit comments