-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (141 loc) · 4.36 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
146
147
148
149
name: Release
on:
schedule:
- cron: '0 0 * * 2'
jobs:
Diff:
runs-on: ubuntu-latest
outputs:
nb: ${{ steps.set-diff.outputs.nb }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
ref: 'stable'
- name: "Check diff"
id: set-diff
run: |
nb=$(git diff --shortstat stable..origin/main | cut -f2 -d ' ')
echo "Find diff: ${nb}"
echo "nb=${nb}" >> "${GITHUB_OUTPUT}"
TagRaw:
needs: Diff
if: ${{ needs.Diff.outputs.nb > 0 }}
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag_label.outputs.tag }}
changelog: ${{ steps.tag_raw.outputs.changelog }}
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: 'Bump version and push tag - dry run'
id: tag_raw
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: stable
tag_prefix:
dry_run: true
- name: 'Format tag'
id: tag_label
env:
TAG: ${{ steps.tag_raw.outputs.new_tag }}
run: |
TAG=$(echo "$TAG" | cut -f1 -d "-")
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
Changelog:
needs: [Diff, TagRaw]
if: ${{ needs.Diff.outputs.nb > 0 }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: 'Check file present'
run: |
[[ -f CHANGELOG.md ]] || touch CHANGELOG.md
- uses: ruby/setup-ruby@v1
with:
ruby-version: 3 # Not needed with a .ruby-version file
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: 'Generate CHANGELOG'
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gem install github_changelog_generator
USER=$(echo "$GITHUB_REPOSITORY" | sed -e 's/\// /g' | awk '{print $1}')
PROJECT=$(echo "$GITHUB_REPOSITORY" | sed -e 's/\// /g' | awk '{print $2}')
echo "$USER $PROJECT"
github_changelog_generator --user "$USER" --project "$PROJECT" --no-unreleased
- name: 'Upload Artifact Changelog'
uses: actions/upload-artifact@v3
with:
name: changelog-artifact
path: CHANGELOG.md
retention-days: 1
Commit:
needs: [Changelog, Diff]
if: ${{ needs.Diff.outputs.nb > 0 }}
runs-on: ubuntu-latest
steps:
# Get Data
- name: 'Checkout'
uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: 'Download Artifact Changelog'
uses: actions/download-artifact@v3
with:
name: changelog-artifact
# Commit
- name: 'Commit files'
run: |
git config --local user.email "$GITHUB_EMAIL"
git config --local user.name "$GITHUB_USERNAME"
git add .
git commit -m "doc(changelog): update"
env:
GITHUB_USERNAME: guillaume-gricourt
GITHUB_EMAIL: [email protected]
- name: 'Push changes'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: 'Update main branch'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: main
Tag:
needs: [Commit, Diff, TagRaw]
if: ${{ needs.Diff.outputs.nb > 0 }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
fetch-depth: 0
- name: 'Bump version and push tag'
id: tag
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
release_branches: stable
custom_tag: ${{ needs.TagRaw.outputs.tag }}
tag_prefix:
Release:
needs: [Diff, TagRaw, Tag]
if: ${{ needs.Diff.outputs.nb > 0 }}
runs-on: ubuntu-latest
steps:
- name: 'Create Release'
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ needs.TagRaw.outputs.tag }}
body: ${{ needs.TagRaw.outputs.changelog }}