Skip to content

Commit a465bae

Browse files
authored
Merge pull request #162 from xsnippet/ci-cd
Refactor CI/CD github actions
2 parents 5dcfe7e + 86b1980 commit a465bae

File tree

3 files changed

+60
-33
lines changed

3 files changed

+60
-33
lines changed

.github/workflows/cd.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: CD
2+
3+
on:
4+
push:
5+
branches: [ "master" ]
6+
tags: [ "*" ]
7+
8+
jobs:
9+
release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: actions/setup-node@v2
15+
16+
- name: Setup dependencies
17+
run: npm install
18+
19+
- name: Build xsnippet-web
20+
run: npm run build
21+
22+
- name: Create xsnippet-web.tar.gz
23+
run: tar cvzf xsnippet-web.tar.gz -C dist/ .
24+
25+
- name: Setup release metadata
26+
run: |
27+
PRERELEASE=true
28+
VERSION=nightly
29+
30+
if [[ $GITHUB_REF =~ ^refs/tags/ ]]; then
31+
if [[ $GITHUB_REF =~ ^refs/tags/v[0-9]+\.[0-9]+(\.[0-9]+)*$ ]]; then
32+
PRERELEASE=false
33+
fi
34+
VERSION="${GITHUB_REF#refs/tags/}"
35+
fi
36+
37+
echo ::set-output name=version::${VERSION}
38+
echo ::set-output name=prerelease::${PRERELEASE}
39+
id: metadata
40+
41+
# Since 'softprops/action-gh-release@v1' does not support release
42+
# re-creation, we have to remove 'nightly' release first.
43+
- name: Remove nightly release
44+
run: |
45+
gh release delete nightly --yes || true
46+
git push origin :nightly || true
47+
env:
48+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
if: steps.metadata.outputs.version == 'nightly'
50+
51+
- name: Create github release
52+
uses: softprops/action-gh-release@v1
53+
with:
54+
tag_name: ${{ steps.metadata.outputs.version }}
55+
prerelease: ${{ steps.metadata.outputs.prerelease}}
56+
target_commitish: ${{ github.sha }}
57+
files: ./xsnippet-web.tar.gz
58+
generate_release_notes: true
59+
fail_on_unmatched_files: true

.github/workflows/test.yml renamed to .github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: test
1+
name: CI
22

33
on:
44
push:

.github/workflows/release.yml

Lines changed: 0 additions & 32 deletions
This file was deleted.

0 commit comments

Comments
 (0)