-
Notifications
You must be signed in to change notification settings - Fork 67
145 lines (121 loc) · 4.31 KB
/
release.yml
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
name: Publish Release
permissions: write-all
on:
workflow_dispatch:
inputs:
milestone:
description: 'The milestone to generate a release for (ex: 6.5.1)'
required: true
type: string
env:
# Needed for GitHub CLI
GH_TOKEN: ${{ github.token }}
defaults:
run:
shell: pwsh
jobs:
build_release_notes:
runs-on: ubuntu-latest
name: Generate Release Notes
steps:
- name: Get Contributors
id: get-contribs
uses: Keboo/GitHubHelper@master
with:
milestone: '${{ inputs.milestone }}'
repository: 'ikabot'
repository-owner: 'Ikabot-Collective'
token: ${{ github.token }}
- name: Generate Release Notes
run: |
$response = gh api --method POST -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/releases/generate-notes -f tag_name='v${{ inputs.milestone }}'
$json = $response | ConvertFrom-Json
$releaseNotes = $json.body
$contributors = "${{ steps.get-contribs.outputs.contributors }}"
$releaseNotes | Out-File -Append "ReleaseNotes.md"
"`n" | Out-File -Append "ReleaseNotes.md"
$contributors | Out-File -Append "ReleaseNotes.md"
cat "ReleaseNotes.md"
- name: Upload Release Notes
uses: actions/upload-artifact@v4
with:
name: ReleaseNotes
path: "ReleaseNotes.md"
update_version_number:
runs-on: ubuntu-latest
name: Update Version Number
steps:
- uses: actions/checkout@v4
- name: Replace version value
run: sed -i 's/IKABOT_VERSION = ".\+"/IKABOT_VERSION = "${{ inputs.milestone }}"/' ikabot/config.py
- name: Push changes
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add ikabot/config.py
git commit -m "Bump Ikabot version ${{ inputs.milestone }}"
git push
build_artifacts:
needs: [update_version_number]
name: Build artifacts
uses: ./.github/workflows/build_artifacts.yml
create_release:
needs: [build_artifacts, build_release_notes]
runs-on: ubuntu-latest
name: Create Draft Release
steps:
- name: Download Pre-Compiled Ikabot Artifacts
uses: actions/download-artifact@v4
with:
name: PreCompiledIkabot
path: pre-compiled-ikabot
- name: Zip Ikabot
run: |
cd pre-compiled-ikabot
zip -r ../Ikabot.zip ikabot/*
cd ..
- name: Download Release Notes
uses: actions/download-artifact@v4
with:
name: ReleaseNotes
- name: Create Release
run: |
# We can't use glob pattern because of this bug https://github.com/cli/cli/issues/5099
gh release create v${{ inputs.milestone }} --repo '${{ github.repository }}' --draft --latest --title "${{ inputs.milestone }}" --notes-file ReleaseNotes.md '${{ github.workspace }}/Ikabot.zip'
publish_release:
needs: [create_release]
runs-on: ubuntu-latest
name: Publish Release
steps:
- name: Publish Release
run: |
gh release edit v${{ inputs.milestone }} --repo '${{ github.repository }}' --draft=false
close_milestone:
needs: [publish_release]
runs-on: ubuntu-latest
name: Close Milestone
steps:
# Doing a checkout, until this issue is resolved.
# https://github.com/valeriobelli/gh-milestone/issues/15
- uses: actions/checkout@v4
- name: Close Milestone
run: |
gh extension install valeriobelli/gh-milestone
$milestones = $(gh milestone list --json number,title) | ConvertFrom-Json
$milestoneNumber = ($milestones | Where-Object { $_.title -eq "${{ inputs.milestone }}" }).number
gh milestone edit $milestoneNumber --state closed
publish_docker:
needs: [publish_release]
name: Publish Docker Image
uses: ./.github/workflows/publish_docker.yml
with:
tag_name: 'v${{ inputs.milestone }}'
permissions:
contents: read
packages: write
publish_pypi:
needs: [publish_release]
name: Publish Python Package
uses: ./.github/workflows/publish_pypi.yml
secrets:
PYPI_API_TOKEN: ${{ secrets.PYPI_API_TOKEN }}