mirror of
https://github.com/ichaly/cohere.git
synced 2026-07-22 07:47:20 +00:00
Automate release on main push
This commit is contained in:
parent
2418195b1a
commit
543e2cdea5
1 changed files with 48 additions and 6 deletions
54
.github/workflows/release.yml
vendored
54
.github/workflows/release.yml
vendored
|
|
@ -2,9 +2,8 @@ name: Release
|
|||
|
||||
on:
|
||||
push:
|
||||
tags:
|
||||
- "v*"
|
||||
- "[0-9]+.[0-9]+.[0-9]+"
|
||||
branches:
|
||||
- main
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
|
|
@ -15,7 +14,9 @@ jobs:
|
|||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup pnpm
|
||||
uses: pnpm/action-setup@v4
|
||||
|
|
@ -23,7 +24,7 @@ jobs:
|
|||
version: 10.33.0
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v6
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 24
|
||||
cache: pnpm
|
||||
|
|
@ -37,21 +38,62 @@ jobs:
|
|||
- name: Build
|
||||
run: pnpm run build
|
||||
|
||||
- name: Prepare release
|
||||
id: release
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ github.token }}
|
||||
run: |
|
||||
VERSION="$(node -p "require('./manifest.json').version")"
|
||||
TAG="v${VERSION}"
|
||||
|
||||
if gh release view "${TAG}" >/dev/null 2>&1; then
|
||||
echo "Release ${TAG} already exists; skipping publish."
|
||||
echo "publish=false" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "publish=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
if git rev-parse "${TAG}" >/dev/null 2>&1; then
|
||||
echo "tag_exists=true" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
echo "tag_exists=false" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
|
||||
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Validate release files
|
||||
if: steps.release.outputs.publish == 'true'
|
||||
env:
|
||||
GITHUB_REF_NAME: ${{ steps.release.outputs.tag }}
|
||||
run: pnpm run release:check
|
||||
|
||||
- name: Stage release assets
|
||||
if: steps.release.outputs.publish == 'true'
|
||||
run: |
|
||||
mkdir -p release
|
||||
cp manifest.json release/manifest.json
|
||||
cp dist/main.js release/main.js
|
||||
cp dist/main.css release/styles.css
|
||||
|
||||
- name: Create tag
|
||||
if: steps.release.outputs.publish == 'true' && steps.release.outputs.tag_exists == 'false'
|
||||
env:
|
||||
TAG: ${{ steps.release.outputs.tag }}
|
||||
run: |
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
||||
git tag "$TAG"
|
||||
git push origin "$TAG"
|
||||
|
||||
- name: Publish GitHub release
|
||||
if: steps.release.outputs.publish == 'true'
|
||||
uses: softprops/action-gh-release@v2
|
||||
with:
|
||||
tag_name: ${{ steps.release.outputs.tag }}
|
||||
name: Obsync ${{ steps.release.outputs.version }}
|
||||
files: |
|
||||
release/manifest.json
|
||||
release/main.js
|
||||
release/styles.css
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue