Skip to content
This repository has been archived by the owner on Nov 22, 2024. It is now read-only.

Add a changelog entry, upgrade dependencies, bump #55

Add a changelog entry, upgrade dependencies, bump

Add a changelog entry, upgrade dependencies, bump #55

Workflow file for this run

name: Release automatically
on:
pull_request:
branches:
- main
types:
- closed
jobs:
release-from-pr:
name: Release from a PR that is marked with [new release]
if: github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'new release')
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎️
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Fetch the version number 📝
id: fetch-version
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const package = require(`${process.env.GITHUB_WORKSPACE}/attractions/package.json`);
return `v${package.version}`;
- name: Fetch the changelog 📝
id: fetch-changelog
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const changelog = require('fs').readFileSync('CHANGELOG.md', { encoding: 'utf-8' }).split('\n');
const start = changelog.findIndex(line => line.startsWith('## '));
const end = changelog.findIndex((line, index) => line.startsWith('## ') && index > start);
return changelog.slice(start + 1, end).join('\n').trim();
- name: Create a release 🔖
uses: actions/github-script@v3
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.repos.createRelease({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: "${{ steps.fetch-version.outputs.result }}",
name: "${{ steps.fetch-version.outputs.result }}",
body: "${{ steps.fetch-changelog.outputs.result }}"
});