diff --git a/.github/workflows/python-app.yml b/.github/workflows/python-app.yml index 4e990be..af6fb6c 100644 --- a/.github/workflows/python-app.yml +++ b/.github/workflows/python-app.yml @@ -1,66 +1,46 @@ -# This workflow will upload a Python Package using Twine when a release is created -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries - -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -name: Upload Python Package +name: Test Publish Release on: - push: - branches: [ "main" ] - + # push: + workflow_dispatch: + inputs: + tool-version: + description: 'The version of the tool to release' + required: true + default: 'v1.0.0' + # tags: + # - "v*" + +permissions: + contents: write jobs: - # test: - # runs-on: macos-latest - # steps: - # - uses: actions/checkout@v2 - # - uses: actions/setup-python@v2 - # with: - # python-version: 3.7 - # - run: | - # echo $PATH - # python --version - # which python - # - run: | - # echo $PATH - # python --version - # which python - # shell: bash {0} - # - run: | - # echo $PATH - # python --version - # which python - # shell: bash -l {0} - - - deploy: - - runs-on: macos-latest - + release: + name: Release pushed tag + runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 - - name: Set up Python - uses: actions/setup-python@v5 - with: - python-version: "3.8.10" - - - - - + - name: Checkout repository + uses: actions/checkout@v4 + - name: Configure Git User + run: | + git config --global user.email "priyagupta108@github.com" + git config --global user.name "priya gupta" + + - name: Tag and Push Release + run: | + git tag -a v1.0.0 -m "Initial release" + git push origin v1.0.0 + - name: Publish Release + id: create_release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + run: | + LATEST_COMMIT=$(git rev-parse HEAD) + LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1)) + gh release create $LATEST_COMMIT --draft --title "Release $LATEST_COMMIT" \ + --tag "${{ inputs.tool-version }}-${{ github.run_id }}" \ + --notes "${{ steps.generate-release-body.outputs.RELEASE_BODY }}" \ + "https://github.com/priyagupta108/sample-python/archive/refs/tags/$LATEST_TAG.zip#sample-python-$LATEST_TAG.zip" \ + "https://github.com/priyagupta108/sample-python/archive/refs/tags/$LATEST_TAG.tar.gz#sample-python-$LATEST_TAG.tar.gz" - - name: Install dependencies - run: | - python -m pip install --upgrade pip - pip install build - - name: Build package - run: python -m build - - name: Publish package - uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 - with: - user: __token__ - password: ${{ secrets.PYPI_API_TOKEN }}