-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (131 loc) · 5.89 KB
/
publish.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
name: Release
on:
schedule:
- cron: 0 0 * * 1,2,3,4,5
workflow_dispatch:
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Ensure we are checked out on the develop branch
ref: develop
# Ensure custom credentials are used when pushing
persist-credentials: false
# Fetch everything so we can checkout master
fetch-depth: 0
- name: Use NodeJS v20
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.x
- name: Compare release versions
id: get-releases
run: |
simple_icons_version="$(curl --retry 5 -s https://api.github.com/repos/simple-icons/simple-icons/releases/latest | jq -r .tag_name)"
echo "si=$simple_icons_version" >> $GITHUB_OUTPUT
echo "lib=$(cat package.json | grep '"version":' | cut -d'"' -f4)" >> $GITHUB_OUTPUT
- name: Bump version
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
run: |
# Update versions in package.json
sed -i \
's/"version": "${{ steps.get-releases.outputs.lib }}",/"version": "${{ steps.get-releases.outputs.si }}",/' \
package.json
sed -i \
's/"simple-icons": "${{ steps.get-releases.outputs.lib }}"/"simple-icons": "${{ steps.get-releases.outputs.si }}"/' \
package.json
# Update version in README
sed -i \
's/${{ steps.get-releases.outputs.lib }}/${{ steps.get-releases.outputs.si }}/g' \
README.md
# Update version in addon
v_major="$(echo ${{ steps.get-releases.outputs.si }} | cut -d'.' -f1)"
v_minor="$(echo ${{ steps.get-releases.outputs.si }} | cut -d'.' -f2)"
v_patch="$(echo ${{ steps.get-releases.outputs.si }} | cut -d'.' -f3)"
sed -i -E \
"s/(\"|')version(\"|'): [(][0-9]+, [0-9]+, [0-9]+[)],/\1version\2: ($v_major, $v_minor, $v_patch),/" \
simple_icons_blender.template
- name: Blender cache setup
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
uses: actions/cache@v4
id: cache-blender
with:
path: |
blender-*
_blender-executable-path.txt
key: ${{ runner.os }}-2.93.9
- name: Download Blender 2.93.9
if: (steps.cache-blender.outputs.cache-hit != 'true' && steps.get-releases.outputs.lib != steps.get-releases.outputs.si)
id: download-blender
run: |
python -m pip install --upgrade blender-downloader
echo "$(blender-downloader 2.93.9 --extract --remove-compressed \
--quiet --print-blender-executable)" > _blender-executable-path.txt
- name: Install dependencies
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
id: install-dependencies
run: |
npm install
python -m pip install --upgrade pip
python -m pip install -r test-requirements.txt
blender_executable="$(< _blender-executable-path.txt tr -d '\n')"
python_blender_executable="$(pytest-blender --blender-executable $blender_executable)"
$python_blender_executable -m ensurepip
$python_blender_executable -m pip install pytest
echo "blender-executable=$blender_executable" >> $GITHUB_OUTPUT
- name: Build library
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
run: npm run build
- name: Test with pytest
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
run: pytest -s --blender-executable "${{ steps.install-dependencies.outputs.blender-executable }}" tests
- name: Commit
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
run: |
set -e
# Set up git credential
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# Create a version bump commit
git add package.json simple_icons_blender.py simple_icons_blender.template README.md
git commit -m "Version bump"
# Merge develop into master
git checkout master
git merge develop -m "Release ${{ steps.get-releases.outputs.si }}"
# Set up remote using a Personal Access Token
git remote remove origin
git remote add origin https://${{secrets.RELEASE_TOKEN}}@github.com/mondeja/simple-icons-blender.git
# Push develop first, to prevent conflicts with parallel activity
git push origin develop
# Push master only after develop was safely pushed
git push origin master
- name: Create and push git tag
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
run: |
set -e
tag="${{ steps.get-releases.outputs.si }}"
git tag -a "${tag}" -m ""
git push origin "${tag}"
- name: Create GitHub release
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
id: create-release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Release ${{ steps.get-releases.outputs.si }}
tag_name: ${{ steps.get-releases.outputs.si }}
body: |
See https://github.com/simple-icons/simple-icons/releases/tag/${{ steps.get-releases.outputs.si }}
- uses: shogo82148/actions-upload-release-asset@v1
name: Upload release asset
if: steps.get-releases.outputs.lib != steps.get-releases.outputs.si
with:
upload_url: ${{ steps.create-release.outputs.upload_url }}
asset_path: simple_icons_blender.py