Skip to content

Commit 1d3a4d3

Browse files
authored
chore: add ci scripts to create github releases (#124)
1 parent 84d016a commit 1d3a4d3

File tree

6 files changed

+1381
-74
lines changed

6 files changed

+1381
-74
lines changed

.github/scripts/env.sh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
# We don't want the `tip` tag to affect our changelog, and also don't want it to be used for the nighly version
5+
git tag -d tip &> /dev/null || :
6+
7+
# PUSHING A TAG TRIGGERS A VERSIONED RELEASE, ANY OTHER PUSH TRIGGERS A NIGHTLY
8+
REF=$(echo "$GITHUB" | jq -r '.ref')
9+
VERSION=$(echo "${REF#refs/tags/}")
10+
11+
# export some data
12+
set-env () {
13+
echo "::set-env name=$1::$2"
14+
export $1="$2"
15+
}
16+
17+
set-env "VERSION" "$VERSION"

.github/scripts/release-notes.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
echo "PATH: $(dirname $(realpath $0))"
5+
6+
: "${ESCAPE:=${GITHUB_ACTIONS:-false}}"
7+
8+
# generate release notes
9+
CHANGELOG="$(npm run --silent ci:changelog)"
10+
11+
# escape newlines for github actions
12+
if [ "$ESCAPE" != false ]; then
13+
echo "escape it"
14+
CHANGELOG="${CHANGELOG//'%'/'%25'}"
15+
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
16+
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
17+
fi
18+
19+
# export some data
20+
echo "::set-output name=changelog::$CHANGELOG"

.github/workflows/cd.yml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
env:
9+
APP_NAME: Testing Playground
10+
NODE_VERSION: "12.x"
11+
12+
jobs:
13+
create-release:
14+
name: Create Release Notes
15+
runs-on: ubuntu-latest
16+
timeout-minutes: 15
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v2
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Fetch all tags
24+
run: git fetch origin +refs/tags/*:refs/tags/*
25+
26+
- uses: actions/setup-node@v1
27+
with:
28+
node-version: "${{ env.NODE_VERSION }}"
29+
30+
- name: Cache node modules
31+
id: cache
32+
uses: actions/cache@v1
33+
with:
34+
path: node_modules
35+
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}
36+
37+
- name: Install Dependencies
38+
if: steps.cache.outputs.cache-hit != 'true'
39+
run: npm ci
40+
- name: Setup Env
41+
run: |
42+
find .github/scripts -type f -iname "*.sh" -exec chmod +x {} \;
43+
.github/scripts/env.sh
44+
env:
45+
GITHUB: ${{ toJson(github) }}
46+
47+
- name: Create Release Notes
48+
id: release_notes
49+
run: .github/scripts/release-notes.sh
50+
51+
- name: Create Release
52+
id: create_release
53+
uses: actions/create-release@v1
54+
with:
55+
tag_name: ${{ github.ref }}
56+
release_name: ${{ env.APP_NAME }} ${{ env.VERSION }}
57+
body: ${{ steps.release_notes.outputs.changelog }}
58+
env:
59+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)