Skip to content

chore: add ci scripts to create github releases #124

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .github/scripts/env.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -euo pipefail

# We don't want the `tip` tag to affect our changelog, and also don't want it to be used for the nighly version
git tag -d tip &> /dev/null || :

# PUSHING A TAG TRIGGERS A VERSIONED RELEASE, ANY OTHER PUSH TRIGGERS A NIGHTLY
REF=$(echo "$GITHUB" | jq -r '.ref')
VERSION=$(echo "${REF#refs/tags/}")

# export some data
set-env () {
echo "::set-env name=$1::$2"
export $1="$2"
}

set-env "VERSION" "$VERSION"
20 changes: 20 additions & 0 deletions .github/scripts/release-notes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -euo pipefail

echo "PATH: $(dirname $(realpath $0))"

: "${ESCAPE:=${GITHUB_ACTIONS:-false}}"

# generate release notes
CHANGELOG="$(npm run --silent ci:changelog)"

# escape newlines for github actions
if [ "$ESCAPE" != false ]; then
echo "escape it"
CHANGELOG="${CHANGELOG//'%'/'%25'}"
CHANGELOG="${CHANGELOG//$'\n'/'%0A'}"
CHANGELOG="${CHANGELOG//$'\r'/'%0D'}"
fi

# export some data
echo "::set-output name=changelog::$CHANGELOG"
59 changes: 59 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Release

on:
push:
tags:
- 'v*'

env:
APP_NAME: Testing Playground
NODE_VERSION: "12.x"

jobs:
create-release:
name: Create Release Notes
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Fetch all tags
run: git fetch origin +refs/tags/*:refs/tags/*

- uses: actions/setup-node@v1
with:
node-version: "${{ env.NODE_VERSION }}"

- name: Cache node modules
id: cache
uses: actions/cache@v1
with:
path: node_modules
key: ${{ runner.os }}-node_modules-${{ hashFiles('**/package-lock.json') }}

- name: Install Dependencies
if: steps.cache.outputs.cache-hit != 'true'
run: npm ci
- name: Setup Env
run: |
find .github/scripts -type f -iname "*.sh" -exec chmod +x {} \;
.github/scripts/env.sh
env:
GITHUB: ${{ toJson(github) }}

- name: Create Release Notes
id: release_notes
run: .github/scripts/release-notes.sh

- name: Create Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref }}
release_name: ${{ env.APP_NAME }} ${{ env.VERSION }}
body: ${{ steps.release_notes.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Loading