-
Notifications
You must be signed in to change notification settings - Fork 53
83 lines (75 loc) · 2.82 KB
/
ci.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
name: CI
on:
push:
branches: [develop]
pull_request:
branches: [develop]
jobs:
checkout:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.matching.outputs.version }}
steps:
- uses: actions/checkout@main
- uses: rundocs/checkout@master
- name: Match the commit message whether to Release!
run: |
MESSAGE=$(git log -1 --format="%s")
if [[ ${MESSAGE} =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
echo "::set-output name=version::${MESSAGE:1}"
fi
id: matching
if: ${{ github.event_name == 'push' }}
release:
runs-on: ubuntu-latest
needs: checkout
if: ${{ needs.checkout.outputs.version }}
env:
VERSION: ${{ needs.checkout.outputs.version }}
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0
- uses: actions/setup-node@main
- uses: actions/setup-ruby@main
- name: Generate changelog and Auto update version!
run: |
LAST_TAG="$(git describe --tags --abbrev=0)"
git log "${LAST_TAG}"..HEAD --no-merges --format="- %h %s @%an" > action.changelog.md
sed -i "s/${LAST_TAG:1}/${VERSION}/g" jekyll-rtd-theme.gemspec
sed -i "s/${LAST_TAG:1}/${VERSION}/g" _includes/rest/defaults.liquid
- name: Prettier check and Build theme assets!
run: |
npm install
npm run format && npm run build
- name: Save changes!
run: |
git remote set-url origin "https://${GITHUB_ACTOR}:${{ secrets.AUTH_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git"
git config user.name "${GITHUB_ACTOR}"
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add .
git commit -m "💎 v${VERSION}" && git push
- name: Create release!
uses: actions/create-release@main
with:
release_name: ${{ needs.checkout.outputs.version }}
tag_name: v${{ needs.checkout.outputs.version }}
commitish: ${{ github.ref }}
body_path: action.changelog.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Configure gem credentials and Build gemspec!
run: |
CONFIG="${HOME}/.gem/credentials"
mkdir -p "${HOME}/.gem" && touch "${CONFIG}" && chmod 0600 "${CONFIG}"
echo "---" > "${CONFIG}"
echo ":github: Bearer ${GITHUB_TOKEN}" >> "${CONFIG}"
echo ":rubygems_api_key: ${RUBYGEMS_AUTH_TOKEN}" >> "${CONFIG}"
gem build ./*.gemspec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUBYGEMS_AUTH_TOKEN: ${{ secrets.RUBYGEMS_AUTH_TOKEN }}
- name: Publish rubygems!
run: |
gem push ./*.gem
gem push --KEY github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} ./*.gem