mirror of
https://github.com/jeffusion/gitea-ai-assistant.git
synced 2026-03-27 10:05:50 +00:00
fix(ci): source Docker tags from semantic-release version
Avoid stale image tags from placeholder package.json and prevent prereleases from overwriting latest.
This commit is contained in:
49
.github/workflows/release.yml
vendored
49
.github/workflows/release.yml
vendored
@@ -40,35 +40,66 @@ jobs:
|
|||||||
run: bun test
|
run: bun test
|
||||||
|
|
||||||
- name: Run semantic-release
|
- name: Run semantic-release
|
||||||
run: bunx semantic-release
|
id: semantic
|
||||||
|
uses: codfish/semantic-release-action@v5
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
|
||||||
|
HUSKY: 0
|
||||||
|
HUSKY_SKIP_HOOKS: 1
|
||||||
|
|
||||||
# Docker build and push
|
# Docker build and push
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Log in to GitHub Container Registry
|
- name: Log in to GitHub Container Registry
|
||||||
|
if: steps.semantic.outputs.new-release-published == 'true'
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ghcr.io
|
registry: ghcr.io
|
||||||
username: ${{ github.repository_owner }}
|
username: ${{ github.repository_owner }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract version from package.json
|
- name: Derive Docker tags from semantic-release
|
||||||
id: package-version
|
if: steps.semantic.outputs.new-release-published == 'true'
|
||||||
|
id: docker-tags
|
||||||
run: |
|
run: |
|
||||||
VERSION=$(node -p "require('./package.json').version")
|
VERSION="${{ steps.semantic.outputs.release-version }}"
|
||||||
echo "version=$VERSION" >> $GITHUB_OUTPUT
|
|
||||||
echo "Detected version: $VERSION"
|
if [ -z "$VERSION" ]; then
|
||||||
|
echo "semantic-release did not provide release-version" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$VERSION" == *"-"* ]]; then
|
||||||
|
TAGS="ghcr.io/${{ github.repository_owner }}/gitea-ai-assistant:${VERSION}"
|
||||||
|
else
|
||||||
|
MAJOR="${VERSION%%.*}"
|
||||||
|
REST="${VERSION#*.}"
|
||||||
|
MINOR="${REST%%.*}"
|
||||||
|
|
||||||
|
TAGS=$(printf '%s\n' \
|
||||||
|
"ghcr.io/${{ github.repository_owner }}/gitea-ai-assistant:latest" \
|
||||||
|
"ghcr.io/${{ github.repository_owner }}/gitea-ai-assistant:${MAJOR}" \
|
||||||
|
"ghcr.io/${{ github.repository_owner }}/gitea-ai-assistant:${MAJOR}.${MINOR}" \
|
||||||
|
"ghcr.io/${{ github.repository_owner }}/gitea-ai-assistant:${VERSION}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
{
|
||||||
|
echo "tags<<EOF"
|
||||||
|
echo "$TAGS"
|
||||||
|
echo "EOF"
|
||||||
|
} >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
echo "Release version: ${VERSION}"
|
||||||
|
echo "Docker tags to push:"
|
||||||
|
echo "$TAGS"
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
|
if: steps.semantic.outputs.new-release-published == 'true'
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: ${{ steps.docker-tags.outputs.tags }}
|
||||||
ghcr.io/${{ github.repository_owner }}/gitea-ai-assistant:latest
|
|
||||||
ghcr.io/${{ github.repository_owner }}/gitea-ai-assistant:${{ steps.package-version.outputs.version }}
|
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "gitea-assistant",
|
"name": "gitea-assistant",
|
||||||
"version": "1.0.0",
|
"version": "0.0.0-develop",
|
||||||
"description": "Gitea功能增强助手,包含AI代码审核功能",
|
"description": "Gitea功能增强助手,包含AI代码审核功能",
|
||||||
"engines": {
|
"engines": {
|
||||||
"bun": ">=1.2.5"
|
"bun": ">=1.2.5"
|
||||||
|
|||||||
Reference in New Issue
Block a user