mirror of
https://github.com/dnote/dnote
synced 2026-03-14 22:45:50 +01:00
99 lines
2.7 KiB
YAML
99 lines
2.7 KiB
YAML
name: Release Server
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'server-v*'
|
|
|
|
jobs:
|
|
release:
|
|
runs-on: ubuntu-22.04
|
|
permissions:
|
|
contents: write
|
|
|
|
steps:
|
|
- uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
- uses: actions/setup-go@v6
|
|
with:
|
|
go-version: '>=1.25.0'
|
|
- uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '20'
|
|
|
|
- name: Extract version from tag
|
|
id: version
|
|
run: |
|
|
TAG=${GITHUB_REF#refs/tags/server-v}
|
|
echo "version=$TAG" >> $GITHUB_OUTPUT
|
|
echo "Releasing version: $TAG"
|
|
|
|
- name: Install dependencies
|
|
run: make install
|
|
|
|
- name: Run tests
|
|
run: make test
|
|
|
|
- name: Build server
|
|
run: make version=${{ steps.version.outputs.version }} build-server
|
|
|
|
- name: Generate changelog
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
TAG="server-v${VERSION}"
|
|
|
|
# Find previous server tag
|
|
PREV_TAG=$(git tag --sort=-version:refname | grep "^server-" | grep -v "^${TAG}$" | head -n 1)
|
|
|
|
if [ -z "$PREV_TAG" ]; then
|
|
echo "Error: No previous server tag found"
|
|
echo "This appears to be the first release."
|
|
exit 1
|
|
fi
|
|
|
|
./scripts/generate-changelog.sh server "$TAG" "$PREV_TAG" > /tmp/changelog.txt
|
|
cat /tmp/changelog.txt
|
|
|
|
- name: Prepare Docker build context
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
cp build/server/dnote_server_${VERSION}_linux_amd64.tar.gz host/docker/
|
|
|
|
- name: Login to Docker Hub
|
|
uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKER_USERNAME }}
|
|
password: ${{ secrets.DOCKER_TOKEN }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: ./host/docker
|
|
push: true
|
|
tags: |
|
|
dnote/dnote:${{ steps.version.outputs.version }}
|
|
dnote/dnote:latest
|
|
build-args: |
|
|
tarballName=dnote_server_${{ steps.version.outputs.version }}_linux_amd64.tar.gz
|
|
|
|
- name: Create GitHub release
|
|
env:
|
|
GH_TOKEN: ${{ github.token }}
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
TAG="server-v${VERSION}"
|
|
|
|
# Determine if prerelease (version not matching major.minor.patch)
|
|
FLAGS=""
|
|
if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
|
FLAGS="--prerelease"
|
|
fi
|
|
|
|
gh release create "$TAG" \
|
|
build/server/*.tar.gz \
|
|
build/server/*_checksums.txt \
|
|
$FLAGS \
|
|
--title="$TAG" \
|
|
--notes-file=/tmp/changelog.txt \
|
|
--draft
|