-
Notifications
You must be signed in to change notification settings - Fork 1.4k
146 lines (141 loc) · 5.24 KB
/
ci-workflow.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
name: CI workflow
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build-test:
name: Build and Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install dependencies
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Built test sites
run: |
bundle exec jekyll build --config _test/_config-version-1.yml --destination ./_test-site-1
bundle exec jekyll build --config _test/_config-version-2.yml --destination ./_test-site-2
- name: Run tests
run: |
bundle exec htmlproofer ./_test-site-1 --disable-external
bundle exec htmlproofer ./_test-site-2 --disable-external
ci-skip:
runs-on: ubuntu-latest
outputs:
skip: ${{ steps.ci-skip-step.outputs.ci-skip }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- id: ci-skip-step
uses: mstachniuk/ci-skip@v1
with:
commit-filter: '[skip ci]'
bump-version-deploy:
name: Bump Version and Deploy
runs-on: ubuntu-latest
needs: [ build-test, ci-skip ]
if: github.ref == 'refs/heads/master' && github.repository_owner == 'sproogen' && needs.ci-skip.outputs.skip == 'false'
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
token: ${{ secrets.ADMIN_TOKEN }}
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- uses: actions/cache@v2
with:
path: vendor/bundle
key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }}
restore-keys: |
${{ runner.os }}-gems-
- name: Install dependencies
run: |
bundle config path vendor/bundle
bundle install --jobs 4 --retry 3
- name: Install gem-release
run: gem install gem-release
- name: Set git config
run: |
git config user.name github-actions
git config user.email [email protected]
- name: Initialize workflow variables
id: vars
run: |
CURRENT_VERSION=$(gem bump --pretend --no-commit | awk '{ print $3 }')
echo ::set-output name=CURRENT_VERSION::${CURRENT_VERSION}
unset HAS_TAG
if [ -n "$(git tag -l v$CURRENT_VERSION)" ]; then HAS_TAG='true'; fi
echo ::set-output name=HAS_TAG::${HAS_TAG}
- name: Bump version if not manually bumped
if: steps.vars.outputs.HAS_TAG
run: |
gem bump --skip-ci
NEW_VERSION=$(gem bump --pretend --no-commit | awk '{ print $3 }')
sed -i -e "s/modern-resume-theme (${{ steps.vars.outputs.CURRENT_VERSION }})/modern-resume-theme (${NEW_VERSION})/g" ./Gemfile.lock
git add Gemfile.lock
git commit --amend --no-edit
- name: Tag latest version
run: gem tag --no-push
- run: git push origin HEAD:${{ github.ref }} --tags
- name: Build Gem
run: gem build modern-resume-theme.gemspec
- name: Get Release Version
id: release_version
run: |
RELEASE_VERSION=$(gem bump --pretend --no-commit | awk '{ print $3 }')
echo ::set-output name=RELEASE_VERSION::${RELEASE_VERSION}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.release_version.outputs.RELEASE_VERSION }}
release_name: v${{ steps.release_version.outputs.RELEASE_VERSION }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./modern-resume-theme-${{ steps.release_version.outputs.RELEASE_VERSION }}.gem
asset_name: modern-resume-theme-${{ steps.release_version.outputs.RELEASE_VERSION }}.gem
asset_content_type: application/octet-stream
- name: Create gem credentials
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
run: |
cat << EOF > ~/.gem/credentials
---
:github: Bearer ${GITHUB_TOKEN}
:rubygems_api_key: ${RUBYGEMS_API_KEY}
EOF
chmod 0600 ~/.gem/credentials
- name: Publish Gem to GitHub Packages
run: gem push --key github --host https://rubygems.pkg.github.com/sproogen modern-resume-theme-${{ steps.release_version.outputs.RELEASE_VERSION }}.gem
- name: Publish Gem to Rubygems
run: gem push modern-resume-theme-${{ steps.release_version.outputs.RELEASE_VERSION }}.gem