Add CI
This commit is contained in:
parent
549124950a
commit
9b61e5d0ea
55
.gitea/workflows/ci.yml
Normal file
55
.gitea/workflows/ci.yml
Normal file
@ -0,0 +1,55 @@
|
||||
name: Build and Publish
|
||||
on:
|
||||
push:
|
||||
tags: ["v*"]
|
||||
|
||||
env:
|
||||
PACKAGE_NAME: eia-api-go
|
||||
BINARY_NAME: eia-client
|
||||
# DOCKER_HOST: "unix:///var/run/user/1000/docker.sock"
|
||||
# DOCKER_ORG: "rmcguire"
|
||||
# DOCKER_LATEST: "latest"
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout Code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Set up Go Environment
|
||||
uses: actions/setup-go@v4
|
||||
with:
|
||||
go-version: '1.23'
|
||||
|
||||
- name: Build Binary
|
||||
run: make all # Build the binary
|
||||
|
||||
- name: Upload Artifact to Gitea
|
||||
env:
|
||||
GITEA_ARTIFACT_SERVER: ${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/generic/${PACKAGE_NAME}
|
||||
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} # Replace with a Gitea token stored in repository secrets
|
||||
run: |
|
||||
if [ -f ./eia-client ]; then
|
||||
curl -X PUT --user ${GITHUB_REPOSITORY_OWNER}:${GITEA_TOKEN} \
|
||||
-F "artifact=@./eia-client" \
|
||||
"$GITEA_ARTIFACT_SERVER/${{ github.ref_name }}/eia-client"
|
||||
else
|
||||
echo "Error: Binary eia-client not found."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
publish:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build # Ensure this stage runs only after 'build' is successful
|
||||
steps:
|
||||
- name: Run Go List
|
||||
env:
|
||||
TAG_NAME: ${{ github.ref_name }} # Use the pushed tag name
|
||||
run: |
|
||||
if [[ "$TAG_NAME" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo GOPROXY=proxy.golang.org go list -m libretechconsulting.com/${GITHUB_REPOSITORY}@$TAG_NAME
|
||||
else
|
||||
echo "Error: Invalid tag format '$TAG_NAME'. Expected 'vX.X.X'."
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue
Block a user