-
Notifications
You must be signed in to change notification settings - Fork 3
146 lines (134 loc) · 4.62 KB
/
release_on_version_push.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: Lint / Test / Release
on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
jobs:
test:
name: Test (Node ${{ matrix.node-version }} on ${{ matrix.os }})
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node-version: [16.x, 18.x]
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- name: Set up NASM (for imagemin binary builds)
uses: ilammy/setup-nasm@v1
- name: Check out repository
uses: actions/checkout@v3
- name: Install Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- run: npm ci
- run: npm run lint
- run: npm run build
- run: npm run test:coverage
- name: Preparing artifact filename
run: |
nodeos="${{ matrix.node-version }}-${{ matrix.os }}"
nodeos="matrix-${nodeos//./_}"
echo "FILENAME=$nodeos" >> $GITHUB_ENV
echo "FILENAME_TXT=${nodeos}.txt" >> $GITHUB_ENV
- name: Setting artifact content
run: |
s=':white_check_mark: '"Node ${{ matrix.node-version }}"
echo "$s" > ${{ env.FILENAME_TXT }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.FILENAME }}
path: ${{ env.FILENAME_TXT }}
release:
name: Create GitHub release
needs: test
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
steps:
- name: Set up NASM (for imagemin binary builds)
uses: ilammy/setup-nasm@v1
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 16.x
registry-url: https://registry.npmjs.org/
- name: Set Git user
run: |
git config --global user.name 'vHeemstra'
git config --global user.email '[email protected]'
# - name: Set output
# id: vars
# run: echo "tag=${GITHUB_REF#refs/*/}" >> $GITHUB_OUTPUT
# - name: Check output
# env:
# RELEASE_VERSION_VIA_OUTPUT: ${{ steps.vars.outputs.tag }}
# run: |
# echo $RELEASE_VERSION_VIA_OUTPUT
# echo ${{ steps.vars.outputs.tag }}
# - name: Set env release version
# run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
# - name: Check env
# run: |
# echo $RELEASE_VERSION
# echo ${{ env.RELEASE_VERSION }}
- name: Download artifacts
uses: actions/download-artifact@v3
# NOTE: if all artifacts are downloaded,
# they will each put in their own folder.
- name: Merge artifact files
run: |
s="### Tested with:"$'\n'"$(cat matrix-**/matrix-*.txt)"$'\n\n'"---"
echo "$s" > matrix-all.txt
- name: Upload merged artifact
uses: actions/upload-artifact@v3
with:
name: matrix-all
path: matrix-all.txt
- name: Create GitHub release
run: |
gh release create $GITHUB_REF_NAME --generate-notes --draft --notes-file matrix-all.txt
cleanup:
name: Clean up
if: ${{ always() }}
needs: [test, release]
runs-on: ubuntu-latest
defaults:
run:
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
steps:
- name: Clean up artifacts
uses: geekyeggo/delete-artifact@v2
with:
name: |
matrix-*
failOnError: false
# This action retreives an empty artifacts list, so it can't remove anything...
# - name: Clean up artifacts
# uses: actions/github-script@v6
# with:
# # GITHUB_TOKEN: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
# github-token: ${{ secrets.GH_PERSONAL_ACCESS_TOKEN }}
# script: |
# const {GITHUB_RUN_ID, GITHUB_REPOSITORY} = process.env
# const artifactsURL = `/repos/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/artifacts`
# console.log(`Deleting artifacs from ${artifactsURL}`)
# const response = await github.request(`GET ${artifactsURL}`)
# console.log(response.data)
# for (artifact of response.data.artifacts) {
# console.log(`Deleting artifact with name=${artifact.name}, id=${artifact.id}`)
# const deleteResponse = await github.request(`DELETE /repos/${repo}/actions/artifacts/${artifact.id}`)
# }