zillionare / python-project-wizard

A tool for creating skeleton python project, built with popular develop tools and conform to best practice.
https://zillionare.github.io/python-project-wizard/
BSD 3-Clause "New" or "Revised" License
123 stars 104 forks source link

add package version to github workflow #20

Closed zillionare closed 1 year ago

zillionare commented 1 year ago

Sometimes we need to get python package version from github workflow CI.

steps:
  - name: Set the value
    id: step_one
    run: |
      echo "action_state=yellow" >> $GITHUB_ENV
  - name: Use the value
    id: step_two
    run: |
      echo "${{ env.action_state }}" # This will output 'yellow'
zillionare commented 1 year ago

add the following:

env.package_version_short
env.package_version_full
env.repo_name
env.repo_owner

they could be used in web hook like this:

      - name: Dingtalk Robot Notify
        uses: leafney/dingtalk-action@v1.0.0
        env: 
          DINGTALK_ACCESS_TOKEN: ${{ secrets.DINGTALK_ACCESS_TOKEN }}
          DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }}
        with:
          msgtype: markdown
          notify_when: 'success'
          title: CI Notification | Success
          text: |
            ### Build success
            ${{ env.package_version_full }} is built and published to test pypi
            ### Change History
            Please check change history at https://${{ env.repo_owner }}.github.io/${{ env.repo_name }}/history
            ### package download
            Please download the pacakge at: https://pypi.org/project/${{ env.repo_name }}/

and the result could be:

### Build success
cfg4py 0.9.3.DEV.22 is built and published to test pypi
### Change History
Please check change history at https://zillionare.github.io/cfg4py/history
### package download
Please download the pacakge at: https://test.pypi.org/project/cfg4py/