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: Set up QEMU uses: docker/setup-qemu-action@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Prepare Docker build context run: | VERSION="${{ steps.version.outputs.version }}" cp build/server/dnote_server_${VERSION}_linux_amd64.tar.gz host/docker/ cp build/server/dnote_server_${VERSION}_linux_arm64.tar.gz host/docker/ cp build/server/dnote_server_${VERSION}_linux_arm.tar.gz host/docker/ cp build/server/dnote_server_${VERSION}_linux_386.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 platforms: linux/amd64,linux/arm64,linux/arm/v7,linux/386 tags: | dnote/dnote:${{ steps.version.outputs.version }} dnote/dnote:latest build-args: | version=${{ steps.version.outputs.version }} - 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