-
Notifications
You must be signed in to change notification settings - Fork 9
97 lines (90 loc) · 3.55 KB
/
_release-github.yml
File metadata and controls
97 lines (90 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
name: (Pre)Release on GitHub
on:
workflow_call:
secrets:
PAT_TOKEN:
description: 'GitHub Personal Access Token'
required: true
inputs:
release_branch:
description: 'Branch to release from. If not provided, will default to main'
default: main
required: false
type: string
jobs:
pre-release:
if: ${{ contains(github.ref, 'rc') }}
runs-on: ubuntu-latest
steps:
- name: Generate GH release notes for pre-release
uses: softprops/action-gh-release@v2
with:
prerelease: true
generate_release_notes: true
token: ${{ secrets.GITHUB_TOKEN }}
release-update-changelog:
if: ${{ !contains(github.ref, 'rc') }}
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v6
with:
token: ${{ secrets.PAT_TOKEN }}
- name: Update CHANGELOG.rst with the latest news
run: |
wget https://raw.githubusercontent.com/scikit-package/release-scripts/v0/.github/workflows/update-changelog.py
python update-changelog.py "${{ github.ref_name }}"
rm update-changelog.py
- name: Commit the changes in CHANGELOG.rst
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: update changelog
branch: ${{ inputs.release_branch }}
release-delete-create-new-tag:
# For a full release, we delete and create a new tag to reflect the latest changes in the CHANGELOG.rst.
# Recall that during the full release, the `main` branch's CHANGELOG.rst has been updated, and we want the
# tag to reflect the latest changes in the CHANGELOG.rst done by the update-changelog above.
# For more discussions, please read https://github.com/scikit-package/release-scripts/pull/120
# Always run this job for a full release but fail if the update-changelog job previously failed.
needs: [release-update-changelog]
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.release_branch }}
- name: Delete the local tag
run: |
git fetch --tags
git tag -d "${{ github.ref_name }}"
- name: Reset the auth to PAT_TOKEN
run:
git config --global --unset-all http.https://github.com/.extraheader || true
git remote set-url origin https://${{ secrets.PAT_TOKEN }}@github.com/${{ github.repository }}.git
- name: Check the GITHUB_TOKEN was successfully unset
run:
git config --get-all http.https://github.com/.extraheader
- name: Push the deleted tag upstream to delete it there
run:
git push origin ":${{ github.ref_name }}"
- name: Create a new tag (Expect commit SHA to match with that of main branch)
run: |
git tag "${{ github.ref_name }}"
git push origin "${{ github.ref_name }}"
release:
needs: [release-delete-create-new-tag]
runs-on: ubuntu-latest
steps:
- name: Checkout the repository
uses: actions/checkout@v6
with:
ref: ${{ inputs.release_branch }}
- name: Generate GH release notes for release
run: |
wget https://raw.githubusercontent.com/scikit-package/release-scripts/v0/.github/workflows/get-latest-changelog.py
python get-latest-changelog.py "${{ github.ref_name }}"
- name: Release
uses: softprops/action-gh-release@v2
with:
body_path: CHANGELOG.txt
token: ${{ secrets.GITHUB_TOKEN }}