Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
- main

jobs:
build_service:
build:
name: Build promgithub
runs-on: ubuntu-24.04

Expand All @@ -24,6 +24,9 @@ jobs:
go-version: 1.22.5
id: go

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build
run: make build

Expand All @@ -39,15 +42,5 @@ jobs:
# with:
# version: v1.50.1

build_container:
name: Build promgithub Container
runs-on: ubuntu-24.04

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build and push
run: make container
47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Release promgithub

on:
push:
branches:
- main
paths:
- 'version'

env:
REGISTRY: ghcr.io
USERNAME: darthfork

permissions:
contents: write
packages: write
issues: write

jobs:
release:
name: Release promgithub
runs-on: ubuntu-24.04

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Golang
uses: actions/setup-go@v5
with:
go-version: 1.22.5
id: go

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ env.USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: make release
29 changes: 23 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@

include version

.DEFAULT_GOAL := help
.DEFAULT_GOAL := help
TARGET := promgithub
SRC := ./...
SRC := ./...
LDFLAGS := -X main.Version=$(VERSION) -s -w
LDFLAGS_DBG := -X main.Version=$(VERSION)
BUILDDIR := build
REGISTRY := ghcr.io/darthfork
REGISTRY := ghcr.io/darthfork/promgithub

help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-10s\033[0m %s\n", $$1, $$2}'
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' Makefile | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

mkdir:
@mkdir -p $(BUILDDIR)
Expand All @@ -26,13 +26,30 @@ debug: LDFLAGS := $(LDFLAGS_DBG)
debug: TARGET := $(TARGET)-debug
debug: all

container: ## Build promgithub service container
@docker build --progress=plain -t $(REGISTRY)/$(TARGET):$(VERSION) .
build-container: ## Build promgithub service container
@docker build --progress=plain -t $(REGISTRY):$(VERSION) .

push-container: ## Push promgithub service container
push-container: build-container
@docker push $(REGISTRY):$(VERSION)

test: GITHUB_WEBHOOK_SECRET := test-secret
test: ## Run unit tests
@go test -v $(SRC)

cross-platform: ## Create cross-platform binaries
cross-platform: mkdir
GOOS=linux GOARCH=amd64 $(MAKE) TARGET=$(TARGET)-linux-amd64-$(VERSION) build
GOOS=linux GOARCH=arm64 $(MAKE) TARGET=$(TARGET)-linux-arm64-$(VERSION) build

release: ## Create github release and upload artifacts
release: cross-platform push-container
@gh release create v$(VERSION)\
--title "promgithub release v$(VERSION)"\
--generate-notes\
$(BUILDDIR)/*


coverage: ## Run unit tests with coverage
@go test -cover -v $(SRC) -coverprofile=coverage.out
@go tool cover -html=coverage.out
Expand Down
56 changes: 56 additions & 0 deletions utils/create_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#!/usr/bin/env bash

OWNER="darthfork"
REPO="promgithub"
RELEASE_NAME="Release v$VERSION"
RELEASE_DESCRIPTION="Description of the release"
ARTIFACTS=(./build/*)

#GITHUB_API="https://api.github.com"
#
## Create a release
#echo "Creating a new GitHub release..."
#response=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
# -H "Accept: application/vnd.github+json" \
# -d "{
# \"tag_name\": \"$VERSION\",
# \"name\": \"$RELEASE_NAME\",
# \"body\": \"$RELEASE_DESCRIPTION\",
# \"draft\": false,
# \"prerelease\": false
# }" \
# "$GITHUB_API/repos/$OWNER/$REPO/releases")
#
## Extract the release ID and upload URL
#release_id=$(echo "$response" | jq -r .id)
#upload_url=$(echo "$response" | jq -r .upload_url | sed -e "s/{?name,label}//")
#
## Check if the release was created successfully
#if [ "$release_id" == "null" ]; then
# echo "Failed to create release. Response:"
# echo "$response"
# exit 1
#else
# echo "Release created with ID: $release_id"
#fi
#
## Upload each artifact
#for ARTIFACT_PATH in "${ARTIFACTS[@]}"; do
# if [ -f "$ARTIFACT_PATH" ]; then
# echo "Uploading artifact: $ARTIFACT_PATH..."
# artifact_name=$(basename "$ARTIFACT_PATH")
#
# curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \
# -H "Content-Type: application/zip" \
# --data-binary @"$ARTIFACT_PATH" \
# "$upload_url?name=$artifact_name"
#
# if [ $? -eq 0 ]; then
# echo "Artifact $artifact_name uploaded successfully!"
# else
# echo "Failed to upload artifact $artifact_name."
# fi
# else
# echo "File $ARTIFACT_PATH does not exist, skipping."
# fi
#done
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/usr/bin/env make

VERSION = 0.0.1
VERSION=0.0.1-a