Skip to content

Commit 853ef42

Browse files
committed
Initial commit
0 parents  commit 853ef42

17 files changed

+3685
-0
lines changed

.github/scripts/check-release.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
repo=$1
4+
release_version=$2
5+
token=$3
6+
7+
echo "Checking release version ${release_version} exists or not."
8+
9+
exists=$(
10+
curl -s \
11+
-H "Accept: application/vnd.github+json" \
12+
-H "Authorization: Bearer ${token}" \
13+
https://api.github.com/repos/${repo}/releases/tags/${release_version} |
14+
jq 'has("id")'
15+
)
16+
17+
if [[ "$exists" == true ]]; then
18+
echo "Release ${release_version} already exists."
19+
echo '::set-output name=release_exists::true'
20+
else
21+
echo '::set-output name=release_exists::false'
22+
fi

.github/scripts/source-tag-sha.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
repo=$1
4+
tag_name=$2
5+
token=$3
6+
7+
sha=$(
8+
curl -s \
9+
-H "Accept: application/vnd.github+json" \
10+
-H "Authorization: Bearer ${token}" \
11+
https://api.github.com/repos/${repo}/git/ref/tags/${tag_name} |
12+
jq '.object.sha' --raw-output
13+
)
14+
15+
if [[ $sha == 'null' ]]; then
16+
echo "Error: Tag name ${tag_name} not found"
17+
exit 1
18+
fi
19+
20+
echo "SHA for ${tag_name}: ${sha}"
21+
echo "::set-output name=sha::$sha"
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
repo=$1
4+
source_tag_sha=$2
5+
major_version=$3
6+
token=$4
7+
8+
curl -s \
9+
-X PATCH -L \
10+
-H "Accept: application/vnd.github+json" \
11+
-H "Authorization: Bearer ${token}" \
12+
https://api.github.com/repos/${repo}/git/refs/tags/${major_version} \
13+
-d '{"sha": "'$source_tag_sha'", "force":true}'

.github/scripts/verify-build.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
# Check if build output at dist is uptodate or not
4+
5+
# Check files updated in working dir
6+
git status dist -s
7+
8+
# Raise error if more than 1 files changed in working dir
9+
if [[ ! -z $(git status dist -s) ]]; then
10+
echo "Build at dist is outdated. Update build, push and try again."
11+
exit 1
12+
fi
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- "main"
8+
paths-ignore:
9+
- "docs/**"
10+
- README.md
11+
- CHANGELOG.md
12+
- .gitignore
13+
14+
jobs:
15+
build:
16+
runs-on: ubuntu-latest
17+
name: Build
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Setup node
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: 12
26+
27+
- name: Install dependencies
28+
run: npm install
29+
30+
- name: Build package
31+
run: npm run build
32+
33+
- name: Verify build
34+
run: .github/scripts/verify-build.sh
35+
36+
release-check:
37+
runs-on: ubuntu-latest
38+
needs: build
39+
name: Release Precheck
40+
41+
steps:
42+
- name: Checkout
43+
uses: actions/checkout@v2
44+
45+
- name: Get version
46+
id: get-version
47+
run: |
48+
version=$(cat package.json | jq '.version' --raw-output)
49+
echo "Version: v${version}"
50+
echo "::set-output name=version::v${version}"
51+
52+
- name: Check if release exists
53+
id: release-check
54+
run: |
55+
.github/scripts/check-release.sh \
56+
${{ github.repository }} \
57+
${{ steps.get-version.outputs.version }} \
58+
${{ secrets.GITHUB_TOKEN }}
59+
60+
- name: Display warning if release exists
61+
if: steps.release-check.outputs.release_exists == 'true'
62+
run: echo "::warning title=Skipping Release::Release ${release_version} already exists. If you want to create new release please update the version in package.json"
63+
64+
outputs:
65+
version: ${{ steps.get-version.outputs.version }}
66+
release_exists: ${{ steps.release-check.outputs.release_exists }}
67+
68+
release:
69+
runs-on: ubuntu-latest
70+
needs: release-check
71+
name: Release
72+
if: needs.release-check.outputs.release_exists == 'false'
73+
steps:
74+
- name: Release
75+
uses: softprops/action-gh-release@v1
76+
with:
77+
name: ${{ needs.release-check.outputs.version }}
78+
tag_name: ${{ needs.release-check.outputs.version }}
79+
generate_release_notes: true
80+
81+
major_version_update:
82+
name: Major Release
83+
needs: [release, release-check]
84+
uses: ./.github/workflows/major-release.yaml
85+
with:
86+
TAG_NAME: ${{ needs.release-check.outputs.version }}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Feature Branch
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
name: Build
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Setup node
17+
uses: actions/setup-node@v3
18+
with:
19+
node-version: 12
20+
21+
- name: Install dependencies
22+
run: npm install
23+
24+
- name: Build package
25+
run: npm run build
26+
27+
- name: Verify build
28+
run: .github/scripts/verify-build.sh
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Update Major Release
2+
3+
on:
4+
release:
5+
types:
6+
- published
7+
8+
workflow_dispatch:
9+
inputs:
10+
TAG_NAME:
11+
description: "Tag name that the major tag will point to"
12+
required: true
13+
type: string
14+
15+
workflow_call:
16+
inputs:
17+
TAG_NAME:
18+
description: "Tag name that the major tag will point to"
19+
required: true
20+
type: string
21+
22+
env:
23+
TAG_NAME: ${{ github.event.release.tag_name || inputs.TAG_NAME }}
24+
25+
jobs:
26+
update_major_tag:
27+
runs-on: ubuntu-latest
28+
name: Update Major Tag
29+
environment: major-release-update
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v2
33+
34+
- name: Get major release version
35+
id: get-major-version
36+
run: |
37+
echo "Tag name: ${TAG_NAME}"
38+
major_version=${TAG_NAME%.*.*}
39+
echo "Major Version: ${major_version}"
40+
echo "::set-output name=major_version::$major_version"
41+
42+
- name: Check if major version exists
43+
id: check-release
44+
run: |
45+
.github/scripts/check-release.sh \
46+
${{ github.repository }} \
47+
${{ steps.get-major-version.outputs.major_version }} \
48+
${{ secrets.GITHUB_TOKEN }}
49+
50+
- name: Get Source Tag SHA
51+
id: source-tag-sha
52+
run: |
53+
.github/scripts/source-tag-sha.sh \
54+
${{ github.repository }} \
55+
${TAG_NAME} \
56+
${{ secrets.GITHUB_TOKEN }}
57+
58+
- name: Create Major Release
59+
uses: softprops/action-gh-release@v1
60+
if: steps.check-release.outputs.release_exists == 'false'
61+
id: create_release
62+
with:
63+
name: ${{ steps.get-major-version.outputs.major_version }}
64+
tag_name: ${{ steps.get-major-version.outputs.major_version }}
65+
target_commitish: ${{ steps.source-tag-sha.outputs.sha }}
66+
67+
- name: Update Major tag
68+
if: steps.check-release.outputs.release_exists == 'true'
69+
run: |
70+
.github/scripts/update-major-tag.sh \
71+
${{ github.repository }} \
72+
${{ steps.source-tag-sha.outputs.sha }} \
73+
${{ steps.get-major-version.outputs.major_version }} \
74+
${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
9+
# Diagnostic reports (https://nodejs.org/api/report.html)
10+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
*.lcov
24+
25+
# nyc test coverage
26+
.nyc_output
27+
28+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
29+
.grunt
30+
31+
# Bower dependency directory (https://bower.io/)
32+
bower_components
33+
34+
# node-waf configuration
35+
.lock-wscript
36+
37+
# Compiled binary addons (https://nodejs.org/api/addons.html)
38+
build/Release
39+
40+
# Dependency directories
41+
node_modules/
42+
jspm_packages/
43+
44+
# TypeScript v1 declaration files
45+
typings/
46+
47+
# TypeScript cache
48+
*.tsbuildinfo
49+
50+
# Optional npm cache directory
51+
.npm
52+
53+
# Optional eslint cache
54+
.eslintcache
55+
56+
# Microbundle cache
57+
.rpt2_cache/
58+
.rts2_cache_cjs/
59+
.rts2_cache_es/
60+
.rts2_cache_umd/
61+
62+
# Optional REPL history
63+
.node_repl_history
64+
65+
# Output of 'npm pack'
66+
*.tgz
67+
68+
# Yarn Integrity file
69+
.yarn-integrity
70+
71+
# dotenv environment variables file
72+
.env
73+
.env.test
74+
75+
# parcel-bundler cache (https://parceljs.org/)
76+
.cache
77+
78+
# Next.js build output
79+
.next
80+
81+
# Nuxt.js build / generate output
82+
.nuxt
83+
84+
# Gatsby files
85+
.cache/
86+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
87+
# https://nextjs.org/blog/next-9-1#public-directory-support
88+
# public
89+
90+
# vuepress build output
91+
.vuepress/dist
92+
93+
# Serverless directories
94+
.serverless/
95+
96+
# FuseBox cache
97+
.fusebox/
98+
99+
# DynamoDB Local files
100+
.dynamodb/
101+
102+
# TernJS port file
103+
.tern-port

0 commit comments

Comments
 (0)