name: Release on: push: tags: - 'v*' jobs: docker: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Set image metadata id: meta run: | TAG="${{ gitea.ref_name }}" VERSION="${TAG#v}" REGISTRY="${{ gitea.server_url }}" # Strip https:// for registry address REGISTRY="${REGISTRY#https://}" REGISTRY="${REGISTRY#http://}" IMAGE="${REGISTRY}/${{ gitea.repository }}" echo "version=${VERSION}" >> "$GITHUB_OUTPUT" echo "image=${IMAGE}" >> "$GITHUB_OUTPUT" echo "tag=${TAG}" >> "$GITHUB_OUTPUT" - name: Login to Gitea Container Registry run: | echo "${{ secrets.DEPLOY_TOKEN }}" | docker login "${{ gitea.server_url }}" -u "${{ gitea.repository_owner }}" --password-stdin - name: Build and push Docker image run: | IMAGE="${{ steps.meta.outputs.image }}" VERSION="${{ steps.meta.outputs.version }}" docker build \ --label "org.opencontainers.image.source=${{ gitea.server_url }}/${{ gitea.repository }}" \ --label "org.opencontainers.image.description=Self-hosted web app launcher dashboard" \ --label "org.opencontainers.image.version=${VERSION}" \ -t "${IMAGE}:${VERSION}" \ -t "${IMAGE}:latest" \ . docker push "${IMAGE}:${VERSION}" docker push "${IMAGE}:latest" release: runs-on: ubuntu-latest needs: docker steps: - name: Fetch RELEASE_NOTES.md only uses: actions/checkout@v4 with: sparse-checkout: RELEASE_NOTES.md sparse-checkout-cone-mode: false - name: Create Gitea release env: DEPLOY_TOKEN: ${{ secrets.DEPLOY_TOKEN }} run: | TAG="${{ gitea.ref_name }}" VERSION="${TAG#v}" BASE_URL="${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}" # Detect pre-release (alpha/beta/rc) IS_PRE="false" if echo "$TAG" | grep -qE '(alpha|beta|rc)'; then IS_PRE="true" fi # Read release notes if present if [ -f RELEASE_NOTES.md ]; then BODY_JSON=$(jq -Rs '.' < RELEASE_NOTES.md) echo "Found RELEASE_NOTES.md" else BODY_JSON='""' echo "No RELEASE_NOTES.md found — release will have no body" fi # Check if release already exists for this tag EXISTING=$(curl -s -o /dev/null -w "%{http_code}" \ "$BASE_URL/releases/tags/$TAG" \ -H "Authorization: token $DEPLOY_TOKEN") if [ "$EXISTING" = "200" ]; then # Update existing release RELEASE_ID=$(curl -s "$BASE_URL/releases/tags/$TAG" \ -H "Authorization: token $DEPLOY_TOKEN" | jq -r '.id') curl -s -X PATCH "$BASE_URL/releases/$RELEASE_ID" \ -H "Authorization: token $DEPLOY_TOKEN" \ -H "Content-Type: application/json" \ -d "{ \"name\": \"$VERSION\", \"body\": $BODY_JSON, \"draft\": false, \"prerelease\": $IS_PRE }" echo "Updated existing release $RELEASE_ID for $TAG" else # Create new release curl -s -X POST "$BASE_URL/releases" \ -H "Authorization: token $DEPLOY_TOKEN" \ -H "Content-Type: application/json" \ -d "{ \"tag_name\": \"$TAG\", \"name\": \"$VERSION\", \"body\": $BODY_JSON, \"draft\": false, \"prerelease\": $IS_PRE }" echo "Created release for $TAG" fi