-
Notifications
You must be signed in to change notification settings - Fork 1
91 lines (75 loc) · 3.75 KB
/
integration-lint-release.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
# This workflow does integration test in cypress, lints javascript and commits to master, and publishes a release with zipped chrome extension.
# lint and release only happens on push (merge) to master.
name: Node.js CI
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
# This job does integration test using cypress, lints javascript and commits to master,
# and publishes zipped chrome-extension on Github Release.
# each step depends on the success of a previous one.
# Currently these are set up in different steps under this same job.
# Alternatively one can set these up in 3 different jobs or even multiple workflow files.
# However these 3 tasks are perfect linear and each one depends on the success of a previous one.
# So setting them up in one job makes sense. It saves github actions run time as well as extra task dependency setup.
test-lint-release:
# add [skip-ci] (in this exact form) in your commit message to skip actions
if: "! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js 14.x
uses: actions/setup-node@v1
with:
node-version: 14.x
- run: yarn --frozen-lockfile
- run: yarn run build_dist --if-present
- run: yarn test
# Now we lint the code. Note we have an if: below, which makes it only run on push, not on pull requests.
- name: Reformat JavaScript
if: github.event_name == 'push'
run: yarn run lint-fix
- name: Git Auto Commit
if: github.event_name == 'push'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "🤖🧹 reformat JavaScript files [skip-ci]"
# Now we publish zipped chrome extension to GitHub releases. This too will only happen on push.
- name: Zip chrome-extension
if: github.event_name == 'push'
# ./dist folder is built during integration testing, so just UTF-8 cleaning and zipping are needed
run: npx ts-node libexec/fix-non-ascii-contentscript.ts && npx ts-node libexec/zip-extension.ts
# date will be used as release tag and name
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d.rc%H%M')"
- name: Create Release
id: create_release
if: github.event_name == 'push'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ steps.date.outputs.date }}
release_name: Release ${{ steps.date.outputs.date }}
# body: |
# Changes in this Release
# - First Change
# - Second Change
# suggestion: create draft releases only and manually publish?
# con: There isn't really a lot for human to manually check...
# nothing is put at stake by publishing some extra packages either.
draft: false
prerelease: false
- name: Upload Release Asset
if: github.event_name == 'push'
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing its ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
asset_path: ./click-in-text.zip
asset_name: click-in-text.zip
asset_content_type: application/zip