mirror of
https://github.com/Heretek-AI/heretek-openclaw-core.git
synced 2026-07-01 14:17:57 -04:00
174 lines
5.0 KiB
YAML
174 lines
5.0 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
- '*/v*'
|
|
|
|
permissions:
|
|
contents: write
|
|
packages: write
|
|
|
|
jobs:
|
|
release:
|
|
name: Create Release
|
|
runs-on: ubuntu-latest
|
|
outputs:
|
|
version: ${{ steps.get_version.outputs.version }}
|
|
component: ${{ steps.get_version.outputs.component }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Get version
|
|
id: get_version
|
|
run: |
|
|
TAG=${GITHUB_REF#refs/tags/}
|
|
VERSION=${TAG##*/v}
|
|
COMPONENT=${TAG%/*}
|
|
if [ "$COMPONENT" = "$TAG" ]; then
|
|
COMPONENT=""
|
|
fi
|
|
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
echo "component=$COMPONENT" >> $GITHUB_OUTPUT
|
|
echo "Version: $VERSION"
|
|
echo "Component: $COMPONENT"
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Generate changelog
|
|
id: changelog
|
|
run: |
|
|
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
|
|
if [ -z "$PREVIOUS_TAG" ]; then
|
|
CHANGELOG=$(git log --pretty=format:"- %s (%h)" HEAD)
|
|
else
|
|
CHANGELOG=$(git log --pretty=format:"- %s (%h)" $PREVIOUS_TAG..HEAD)
|
|
fi
|
|
echo "changelog<<EOF" >> $GITHUB_OUTPUT
|
|
echo "$CHANGELOG" >> $GITHUB_OUTPUT
|
|
echo "EOF" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create GitHub Release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref }}
|
|
release_name: Release ${{ steps.get_version.outputs.version }}
|
|
body: |
|
|
## Changes
|
|
|
|
${{ steps.changelog.outputs.changelog }}
|
|
|
|
## Installation
|
|
|
|
```bash
|
|
npm install @heretek/openclaw-${{ steps.get_version.outputs.component }}@${{ steps.get_version.outputs.version }}
|
|
```
|
|
draft: false
|
|
prerelease: ${{ contains(github.ref, 'beta') || contains(github.ref, 'alpha') }}
|
|
|
|
publish-npm:
|
|
name: Publish to npm
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: ${{ !contains(needs.release.outputs.component, 'deploy') && !contains(needs.release.outputs.component, 'docs') }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
cache: 'npm'
|
|
registry-url: 'https://registry.npmjs.org'
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Update version
|
|
run: npm version ${{ needs.release.outputs.version }} --no-git-tag-version
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Publish to npm
|
|
run: npm publish --access public
|
|
env:
|
|
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
|
|
- name: Create npm release notes
|
|
run: |
|
|
echo "Published @heretek/openclaw-${{ needs.release.outputs.component }}@${{ needs.release.outputs.version }} to npm"
|
|
|
|
publish-docker:
|
|
name: Publish to Docker Hub
|
|
runs-on: ubuntu-latest
|
|
needs: release
|
|
if: ${{ needs.release.outputs.component == 'core' || needs.release.outputs.component == '' }}
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
heretek/openclaw:${{ needs.release.outputs.version }}
|
|
heretek/openclaw:latest
|
|
platforms: linux/amd64,linux/arm64
|
|
cache-from: type=registry,ref=heretek/openclaw:buildcache
|
|
cache-to: type=registry,ref=heretek/openclaw:buildcache,mode=max
|
|
|
|
notify:
|
|
name: Notify
|
|
runs-on: ubuntu-latest
|
|
needs: [release, publish-npm, publish-docker]
|
|
if: always()
|
|
steps:
|
|
- name: Notify Slack
|
|
uses: slackapi/slack-github-action@v1
|
|
if: ${{ needs.release.result == 'success' }}
|
|
with:
|
|
payload: |
|
|
{
|
|
"text": "🚀 Released: ${{ github.repository }} v${{ needs.release.outputs.version }}",
|
|
"blocks": [
|
|
{
|
|
"type": "section",
|
|
"text": {
|
|
"type": "mrkdwn",
|
|
"text": "🚀 *New Release*\n*${{ github.repository }}* v${{ needs.release.outputs.version }}\n${{ github.event.release.html_url }}"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
env:
|
|
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|