Skip to content
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

Add GitHub actions for releasing on GitHub #407

Merged
merged 1 commit into from Jan 15, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
@@ -0,0 +1,37 @@
name: Release

on:
push:
tags: ["v*"]

jobs:
release:
name: Trigger release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1

- name: Generate the changelog
id: changelog
uses: cliqz-oss/adblocker/generate-changelog
env:
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}

- name: Create a GitHub release
uses: cliqz-oss/adblocker/publish-github-release
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Commit CHANGELOG.md
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add CHANGELOG.md
git commit -m "Update CHANGELOG.md [skip ci]" --no-verify --quiet

- name: Push CHANGELOG.md
uses: ad-m/github-push-action@v0.5.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: 'master'
force: false
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
@@ -1,6 +1,6 @@
name: Tests

on: [push, pull_request]
on: [pull_request]

jobs:
test:
Expand Down
10 changes: 10 additions & 0 deletions actions/generate-changelog/action.yml
@@ -0,0 +1,10 @@
name: Generate changelog
description: Uses lerna-changelog to create CHANGELOG.md

runs:
using: node12
main: main.js

branding:
icon: clock
color: yellow
20 changes: 20 additions & 0 deletions actions/generate-changelog/main.js
@@ -0,0 +1,20 @@
const { writeFileSync } = require('fs');
const { resolve } = require('path');

const { execSync } = require('child_process');
execSync(`cd ${__dirname}; npm ci`);

const currentTag = execSync(`git describe --abbrev=0 --tags ${process.env.GITHUB_SHA}`)
.toString()
.trim();

writeFileSync(
resolve(process.env.GITHUB_WORKSPACE, 'CHANGELOG.md'),
execSync(
`node ${resolve(
__dirname,
'node_modules/.bin/lerna-changelog',
)} --from v1.0.0 --to ${currentTag}`,
).toString().trim(),
'utf-8',
);