This repository was archived by the owner on Feb 6, 2025. It is now read-only.
Merge pull request #26 from notguoxin/dev #130
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release | |
permissions: | |
pull-requests: write | |
contents: write | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- '*.md' | |
jobs: | |
release: | |
continue-on-error: false | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Get version number from package.json | |
id: get_version | |
run: | | |
VERSION=$(jq -r '.version' package.json) | |
echo "::set-output name=version::$VERSION" | |
- uses: mukunku/tag-exists-action@16e94379f4a0448da8ec100d16d3dc50b49cbd52 | |
id: check-tag | |
with: | |
tag: 'v${{ steps.get_version.outputs.version }}' | |
- uses: actions/setup-node@v4 | |
if: steps.check-tag.outputs.exists == 'false' | |
with: | |
node-version: 18 | |
- uses: actions/setup-python@v5 | |
if: steps.check-tag.outputs.exists == 'false' | |
with: | |
python-version: 3.11 | |
- name: Clean npm cache | |
if: steps.check-tag.outputs.exists == 'false' | |
id: clean_cache | |
run: npm cache clean --force | |
- name: Cache npm dependencies | |
if: steps.check-tag.outputs.exists == 'false' | |
uses: actions/cache@v3 | |
with: | |
path: ~/.npm | |
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-npm- | |
- name: Build | |
if: steps.check-tag.outputs.exists == 'false' && steps.clean_cache.conclusion == 'success' | |
run: | | |
python -m pip install --upgrade pip | |
pip install build | |
python -m build . | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Create GitHub release | |
if: steps.check-tag.outputs.exists == 'false' | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const path = require('path'); | |
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: "", | |
}); | |
const uploadUrl = release.data.upload_url; | |
const filePath = path.join('dist', `open_webui-${{ steps.get_version.outputs.version }}-py3-none-any.whl`); | |
const stat = fs.statSync(filePath); | |
await github.rest.repos.uploadReleaseAsset({ | |
url: uploadUrl, | |
headers: { | |
'content-length': stat.size, | |
'content-type': 'application/octet-stream', | |
}, | |
name: path.basename(filePath), | |
data: fs.readFileSync(filePath), | |
}); | |
console.log(`Created release ${release.data.html_url}`); | |
- name: Upload artifacts to release | |
if: steps.check-tag.outputs.exists == 'false' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: package | |
path: | | |
. | |
!.git | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |