From 4d4f3d5baf196038ce77e6231d417cd6a351b5cd Mon Sep 17 00:00:00 2001 From: Andrii Lytovchenko Date: Mon, 13 Dec 2021 01:24:27 +0100 Subject: [PATCH 1/2] feat: add deployment action --- .github/workflows/deployment.yml | 51 ++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 .github/workflows/deployment.yml diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml new file mode 100644 index 0000000..4391edb --- /dev/null +++ b/.github/workflows/deployment.yml @@ -0,0 +1,51 @@ +name: Deployment + +on: + push: + tags: + - v1r[0-9]+ + pull_request: + +jobs: + deploy-pypi: + name: PyPI deployment + runs-on: "ubuntu-latest" + if: github.event_name != 'push' || github.repository == 'DIRACGrid/COMDIRAC' + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: "3.9" + - name: Install dependencies + run: pip install build readme_renderer diraccfg + - name: Validate README for PyPI + run: python -m readme_renderer README.rst -o /tmp/README.html + - name: Make PEP-440 style release on GitHub + id: PEP-440 + if: github.event_name == 'push' + run: | + TAG_NAME=${GITHUB_REF##*/} + NEW_STYLE=$(python -c "import diraccfg; major, minor, patch, pre = diraccfg.parseVersion('${TAG_NAME}'); print(f'{major}.{minor}.{patch}', f'a{pre}' if pre else '', sep='')") + echo "Converted ${TAG_NAME} version to ${NEW_STYLE}" + echo ::set-output name=tag_name::"v$NEW_STYLE" + echo ::set-output name=target_commitish::"$(git rev-parse HEAD)" + - name: Publish ${{ steps.PEP-440.outputs.tag_name }} release to GitHub + if: github.event_name == 'push' + uses: softprops/action-gh-release@v1 + with: + target_commitish: ${{ steps.PEP-440.outputs.target_commitish }} + body_path: release.notes + tag_name: ${{ steps.PEP-440.outputs.tag_name }} + - name: Get ${{ steps.PEP-440.outputs.tag_name }} tag + if: github.event_name == 'push' + uses: actions/checkout@v2 + with: + ref: ${{ steps.PEP-440.outputs.tag_name }} + - name: Build distributions + run: python -m build + - name: Publish package on PyPI + if: github.event_name == 'push' + uses: pypa/gh-action-pypi-publish@master + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} From 070ffbc39c5676d79725c2aaaef6fd409710713c Mon Sep 17 00:00:00 2001 From: Andrii Lytovchenko Date: Mon, 13 Dec 2021 21:53:55 +0100 Subject: [PATCH 2/2] feat: add deployment action --- .github/workflows/deployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deployment.yml b/.github/workflows/deployment.yml index 4391edb..1b3ed48 100644 --- a/.github/workflows/deployment.yml +++ b/.github/workflows/deployment.yml @@ -19,7 +19,7 @@ jobs: - name: Install dependencies run: pip install build readme_renderer diraccfg - name: Validate README for PyPI - run: python -m readme_renderer README.rst -o /tmp/README.html + run: python -m readme_renderer README.* -o /tmp/README.html - name: Make PEP-440 style release on GitHub id: PEP-440 if: github.event_name == 'push'