1- name : Start a new release
1+ name : Release and publish a new version
22
33on :
44 workflow_dispatch :
2727 run : |
2828 echo "Job failed due to user not being a member of Giskard-AI organization and the 'safe for build' label not being set on the PR"
2929 exit 1
30+
31+ - name : Write release version env vars (with/without v)
32+ run : |
33+ VERSION_NAME="v${{ inputs.version }}"
34+ VERSION_NUMBER="${VERSION_NAME:1}"
35+ echo "VERSION_NUMBER=${VERSION_NUMBER}" >> $GITHUB_ENV
36+ echo "VERSION_NAME=${VERSION_NAME}" >> $GITHUB_ENV
3037
3138 - name : Checkout code
3239 uses : actions/checkout@v4.1.0
3643 token : ${{ secrets.RELEASE_PAT_TOKEN }} # Needed to trigger other actions
3744
3845 - name : Edit pyproject.toml
39- run : sed -i 's/^\(version *= *\).*$/\1"${{ inputs.version }}"/' pyproject.toml
46+ run : sed -i 's/^\(version *= *\).*$/\1"${{ env.VERSION_NUMBER }}"/' pyproject.toml
4047
4148 - name : Remove dark theme logo from README
4249 run : sed -i 's/.*#gh-dark-mode-only.*//' README.md
@@ -47,36 +54,74 @@ jobs:
4754 python-version : ' 3.10'
4855 cache : false
4956
50- - name : Build release candidate wheel
51- run : pdm build
52-
53- - name : Upload RC wheel artifact
54- uses : actions/upload-artifact@v4
55- with :
56- name : rc-wheel-${{ inputs.version }}
57- path : dist/*whl
58- if-no-files-found : error
59- retention-days : 1
60-
6157 - name : " @slack Release process started"
6258 id : slack
6359 uses : slackapi/slack-github-action@v1.26.0
6460 with :
6561 channel-id : ${{ vars.SLACK_CHANNEL_ID }}
6662 slack-message : |-
67- Release *v ${{ inputs.version }}* is on the way :rocket:
63+ Release *${{ env.VERSION_NAME }}* is on the way :rocket:
6864 <${{ github.server_url }}/${{ github.actor }}|@${{ github.actor }}> | <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|commit> <!channel>
6965 env :
7066 SLACK_BOT_TOKEN : ${{ secrets.SLACK_BOT_TOKEN }}
7167
72- - name : Trigger release process in legacy-hub
73- uses : peter-evans/repository-dispatch@v3
68+ - name : Configure git
69+ run : |
70+ git config --global user.name 'BotReleaser'
71+ git config --global user.email 'bot.releaser@users.noreply.github.com'
72+
73+ - name : Adding file
74+ run : |
75+ git add pyproject.toml
76+ git fetch --quiet --tags
77+ git commit -m "${{ env.VERSION_NAME }}" --allow-empty
78+ git tag ${{ env.VERSION_NAME }}
79+
80+ - name : Push to main and tags
81+ run : |
82+ git push origin main
83+ git push origin ${{ env.VERSION_NAME }}
84+
85+ # build .tar.gz sdist tarball
86+ - name : Build source distribution tarball
87+ run : pdm build
88+
89+ - name : Create Github Release
90+ id : github-release
91+ uses : softprops/action-gh-release@v2
92+ with :
93+ tag_name : ${{ env.VERSION_NAME }}
94+ fail_on_unmatched_files : true
95+ generate_release_notes : true
96+ files : |
97+ dist/giskard-*.tar.gz
98+ dist/giskard-*.whl
99+
100+ - name : Push to Pipy
101+ run : pdm publish --no-build --username "${{ secrets.PIPY_USERNAME }}" --password "${{ secrets.PIPY_PASSWORD }}"
102+
103+ - name : Set job success env var
104+ run : |
105+ echo "JOB_SUCCESS=true" >> $GITHUB_ENV
106+
107+ - name : " @slack Share release process completion"
108+ # cancellable always() https://docs.github.com/en/actions/learn-github-actions/expressions#status-check-functions
109+ if : ${{ !cancelled() }}
110+ uses : slackapi/slack-github-action@v1.26.0
111+ env :
112+ SLACK_BOT_TOKEN : ${{ secrets.SLACK_BOT_TOKEN }}
113+ ON_SUCCESS : |-
114+ *${{ env.VERSION_NAME }}* has been published to PyPI ! :python: :tada:
115+ <${{ steps.github-release.outputs.url }}|Release notes> | <https://pypi.org/project/giskard/${{ env.VERSION_NUMBER }}|PyPI> <!channel>
116+ ON_FAILURE : |-
117+ Could not publish *${{ env.VERSION_NAME }}* to PyPI :x:
118+ <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|logs> <!channel>
74119 with :
75- token : ${{ secrets.RELEASE_PAT_TOKEN }}
76- event-type : create-release
77- repository : ${{ github.repository_owner }}/legacy-hub
78- client- payload : |
120+ channel-id : ${{ vars.SLACK_CHANNEL_ID }}
121+ slack-message : ${{ env.JOB_SUCCESS == 'true' && env.ON_SUCCESS || env.ON_FAILURE }}
122+ # reploy_broadcast == also send to channel
123+ payload : |
79124 {
80- "version_name ": "v ${{ inputs.version }}",
81- "slack_thread_id ": "${{ steps.slack.outputs.thread_ts }}"
82- }
125+ "thread_ts ": "${{ steps.slack.outputs.thread_ts }}",
126+ "reply_broadcast ": true
127+ }
0 commit comments