-
-
Notifications
You must be signed in to change notification settings - Fork 202
158 lines (140 loc) · 6.49 KB
/
merge.yaml
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
150
151
152
153
154
155
156
157
158
name: Merge to release
on:
push:
branches:
- master
tags-ignore:
- '**'
workflow_dispatch:
inputs:
commit_message:
description: Commit message
required: true
permissions: {}
jobs:
release:
permissions:
contents: write # to create a release
pull-requests: read # to read pull requests (dorny/paths-filter)
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
DISTRIBUTION_UPDATER_TOKEN: "${{ secrets.DISTRIBUTION_UPDATER_TOKEN }}"
steps:
- uses: actions/checkout@v3
if: github.event_name == 'push'
- uses: actions/checkout@v3
if: github.event_name == 'workflow_dispatch'
with:
fetch-depth: 0
- name: Release branch version
id: release
run: echo ::set-output name=branch::v1.0.2
- name: Checkout release branch
uses: actions/checkout@v3
with:
ref: ${{ steps.release.outputs.branch }}
path: './release'
- name: Check for relevant changes
if: github.event_name == 'push'
uses: dorny/paths-filter@v3
id: update
with:
list-files: shell
filters: |
updated:
- added|modified: [ '*.csl', 'dependent/*.csl', '*.xml', 'README.md' ]
deleted:
- deleted: [ '*.csl', 'dependent/*.csl', '*.xml' ]
workflows:
- added|modified: .github/workflows/*.yaml
updated_composer:
- added|modified: composer.json
deleted_composer:
- deleted: composer.json
- name: Changed files
if: github.event_name == 'push'
run: |
echo updated: ${{ steps.update.outputs.updated_files }}
echo deleted: ${{ steps.update.outputs.deleted_files }}
echo workflows: ${{ steps.update.outputs.workflows_files }}
- name: Set up Ruby
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true'))
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.0.2
- name: but use cache to speed that up
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true'))
uses: actions/cache@v4
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Bundle install
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true'))
run: |
bundle config path vendor/bundle
bundle update sheldon --jobs 4 --retry 3
- name: Populate new branch
run: bundle exec sheldon --token=$GITHUB_TOKEN --verbose --populate release
if: github.event_name == 'workflow_dispatch'
- name: update the timestamps and add the changes
run: bundle exec sheldon --token=$GITHUB_TOKEN --verbose --release release ${{ steps.update.outputs.updated_files }}
if: github.event_name == 'push' && steps.update.outputs.updated == 'true'
- name: delete deleted files
run: cd release && git rm ${{ steps.update.outputs.deleted_files }}
if: github.event_name == 'push' && steps.update.outputs.deleted == 'true'
- name: Update composer.json
if: steps.update.outputs.updated_composer == 'true'
run: |
cp composer.json release/composer.json
cd release
git add composer.json
- name: Delete composer.json
if: steps.update.outputs.deleted_composer == 'true'
run: |
cd release
git rm composer.json
- uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: 'release'
commit_message: Releasing ${{ steps.update.outputs.updated_files }} ${{ steps.update.outputs.deleted_files }} ${{ steps.update.outputs.updated_composer_files }} ${{ steps.update.outputs.deleted_composer_files }}
if: github.event_name == 'push' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true' || steps.update.outputs.updated_composer == 'true' || steps.update.outputs.deleted_composer == 'true')
- uses: stefanzweifel/git-auto-commit-action@v5
with:
repository: 'release'
commit_message: ${{ github.event.inputs.commit_message }}
if: github.event_name == 'workflow_dispatch'
# https://styles-update.zotero.org:8826/ is for Zotero (styles page, API's citation server, client style updates, etc.)
- name: ping Zotero servers
if: github.repository == 'citation-style-language/styles'
run: |
curl -H 'Content-Length:' -H "Authorization: $ZOTERO_UPDATE_TOKEN" -d 'payload={"type":"push","branch":"${{ steps.release.outputs.branch }}","status":0,"commit":"'$GITHUB_SHA'"}' https://styles-update.zotero.org:8826/
- name: Copy workflows to locales repository
if: github.repository == 'citation-style-language/styles' && steps.update.outputs.workflows == 'true'
uses: drud/action-cross-commit@master
with:
source-folder: .github/workflows
destination-repository: https://csl-bot:${{ secrets.CSLBOT_TOKEN }}@github.com/citation-style-language/locales
destination-folder: .github/workflows
destination-branch: master
git-user: "csl-bot"
git-user-email: [email protected]
git-commit-message: copied ${{ steps.update.outputs.workflows_files }} from styles
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
default_bump: patch
if: github.event_name == 'push' && hashFiles('composer.json') != '' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true')
- name: Create a GitHub release
uses: softprops/action-gh-release@v2
env:
github_token: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: Released ${{ steps.update.outputs.updated_files }} ${{ steps.update.outputs.deleted_files }} ${{ steps.update.outputs.updated_composer_files }} ${{ steps.update.outputs.deleted_composer_files }}
if: github.event_name == 'push' && hashFiles('composer.json') != '' && (steps.update.outputs.updated == 'true' || steps.update.outputs.deleted == 'true')