forked from open-webui/open-webui
95b20f3cb8
This should show the latest Changes in the CHANGELOG.md file when creating a new release. For now it only shows "Automatically created new release". It is running 'awk '/^## [/{n++} n==1' CHANGELOG.md' which extracts the latest changes. Note: I only tested the command on my linux machine, worked.
59 lines
1.7 KiB
YAML
59 lines
1.7 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main # or whatever branch you want to use
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v2
|
|
|
|
- name: Check for changes in package.json
|
|
run: |
|
|
git diff --cached --diff-filter=d package.json || {
|
|
echo "No changes to package.json"
|
|
exit 1
|
|
}
|
|
|
|
- name: Get version number from package.json
|
|
id: get_version
|
|
run: |
|
|
VERSION=$(jq -r '.version' package.json)
|
|
echo "::set-output name=version::$VERSION"
|
|
|
|
- name: Extract latest CHANGELOG entry
|
|
id: changelog
|
|
run: |
|
|
CHANGELOG_CONTENT=$(awk '/^## \[/{n++} n==1' CHANGELOG.md)
|
|
echo "CHANGELOG_CONTENT<<EOF"
|
|
echo "$CHANGELOG_CONTENT"
|
|
echo "EOF"
|
|
echo "::set-output name=content::${CHANGELOG_CONTENT}"
|
|
|
|
- name: Create GitHub release
|
|
uses: actions/github-script@v5
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const changelog = `${{ steps.changelog.outputs.content }}`;
|
|
const release = await github.rest.repos.createRelease({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
tag_name: `v${{ steps.get_version.outputs.version }}`,
|
|
name: `v${{ steps.get_version.outputs.version }}`,
|
|
body: changelog,
|
|
})
|
|
console.log(`Created release ${release.data.html_url}`)
|
|
|
|
- name: Upload package to GitHub release
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: package
|
|
path: .
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|