-
-
Notifications
You must be signed in to change notification settings - Fork 15
104 lines (101 loc) · 3.83 KB
/
auto-release.yml
File metadata and controls
104 lines (101 loc) · 3.83 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
98
99
100
101
102
103
104
name: Automated Releases
on:
# This Workflow is triggered through the GitHub API:
# curl -X Post \
# -H "Authorization: Bearer <token>" \
# -d '{"ref":"develop"}' \
# https://api.github.com/repos/simple-icons/simple-icons-font/actions/workflows/auto-release.yml/dispatches
# Replacing <token> by a personal access token with scope `public_repo`
workflow_dispatch:
# It is also triggered on a schedule, every Tuesday, Thursday, and Saturday at midnight UTC.
# This is to ensure that the fonts are released regularly, if, for some reason, the
# previous workflow dispatch failed to trigger a release.
schedule:
- cron: 0 0 * * 2,4,6
jobs:
check-is-fork:
name: Check if running in a fork
runs-on: ubuntu-latest
outputs:
is-fork: ${{ steps.check.outputs.is-fork }}
steps:
- uses: actions/checkout@v5
- uses: ./.github/actions/check-is-fork
id: check
with:
in-fork-message: 'Auto release only can be executed in the main repository, skipping.'
get-releases:
name: Get release versions
runs-on: ubuntu-latest
needs: check-is-fork
if: needs.check-is-fork.outputs.is-fork != 'true'
outputs:
si: ${{ steps.get-releases.outputs.si }}
lib: ${{ steps.get-releases.outputs.lib }}
steps:
- uses: actions/checkout@v5
with:
ref: develop
- name: Compare release versions
id: get-releases
run: |
simple_icons_version="$(curl --retry 15 -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
auto-release:
name: Automated release
runs-on: ubuntu-latest
needs: get-releases
if: needs.get-releases.outputs.si != needs.get-releases.outputs.lib
steps:
- uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ vars.BOT_APP_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v5
with:
token: ${{ steps.app-token.outputs.token }}
# Ensure we are checked out on the develop branch
ref: develop
# Fetch everything so we can checkout master
fetch-depth: 0
- name: Use Node.js
uses: actions/setup-node@v6
with:
node-version-file: .node-version
cache: npm
- name: Install dependencies
run: npm ci
- name: Update README CDN URLs
# Update CDN URLs in README
run: node scripts/update-cdn-urls.ts
- name: Update simple-icons dependency and package version
id: update
run: |
new_version="$(node scripts/bump-version.ts)"
echo "new-version=$new_version" >> $GITHUB_OUTPUT
- name: Sanity check
run: npm run build
- name: Configure GIT credentials
run: |
git config user.name "simple-icons[bot]"
git config user.email "simple-icons[bot]@users.noreply.github.com"
- name: Commit updates
run: |
git add .
git commit -m "Bump version"
- name: Merge develop into master
run: |
git checkout master
git merge develop --no-ff -m "Release ${{ steps.update.outputs.new-version }}"
- name: Push version bump
run: |
# Set up remote using a Personal Access Token
git remote remove origin
git remote add origin https://${{ secrets.RELEASE_TOKEN }}@github.com/simple-icons/simple-icons-font.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