Skip to content

Commit

Permalink
chore(github actions): Add action to trigger release manually
Browse files Browse the repository at this point in the history
  • Loading branch information
burtek committed Apr 15, 2024
1 parent c27f89d commit 80b76d4
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: 'Setup node'
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
- name: 'Install dependencies'
run: yarn
# - name: 'Test configs'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Make github and npm releases'
name: 'Create github and npm releases'

on:
push:
Expand All @@ -9,14 +9,16 @@ jobs:
make-release:
name: 'Make github and npm releases'
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: 'Checkout source code'
uses: 'actions/checkout@v4'
- name: 'Setup node'
uses: actions/setup-node@v4
with:
node-version: '18.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
scope: '@dtrw'
- name: 'Install dependencies'
Expand All @@ -31,11 +33,15 @@ jobs:
run: "yarn publish --tag ${{ ((contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta')) && 'next') || 'latest' }} --access public"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Generate Changelog
run: |
START=$(grep -n "## \[" CHANGELOG.md | head -n 1 | cut -d : -f 1)
END=$(grep -n "## \[" CHANGELOG.md | head -n 2 | tail -n 1 | cut -d : -f 1)
awk "NR > $START && NR < $END" CHANGELOG.md | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' > ${{ github.workspace }}-CHANGELOG.temp.md
- name: 'Create a github release'
uses: "marvinpinto/action-automatic-releases@latest"
# TODO: https://github.com/marvinpinto/actions/pull/642
# TODO: body/content
uses: softprops/action-gh-release@v2
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: ${{ contains(github.ref_name, '-alpha') || contains(github.ref_name, '-beta') }}
automatic_release_tag: "${{ github.ref_name }}"
tag_name: "${{ github.ref_name }}"
body_path: ${{ github.workspace }}-CHANGELOG.temp.md
43 changes: 43 additions & 0 deletions .github/workflows/trigger-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 'Trigger a release'

on:
workflow_dispatch:
inputs:
alpha:
type: boolean
description: 'Alpha release?'

jobs:
default:
name: 'Trigger a release'
runs-on: ubuntu-latest
permissions:
contents: write

steps:
- name: 'Checkout source code'
uses: 'actions/checkout@v4'
- name: 'Setup node'
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: 'Install dependencies'
run: yarn
# - name: 'Test configs'
# run: yarn test
- name: 'Lint configs'
run: yarn lint
- name: 'Setup git'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
- name: 'Create release'
if: ${{ !github.event.inputs.alpha }}
run: yarn release
- name: 'Create alpha release'
if: ${{ github.event.inputs.alpha }}
run: yarn release:alpha
- name: 'Push release'
uses: ad-m/github-push-action@master
with:
branch: master

0 comments on commit 80b76d4

Please sign in to comment.