From 9b61e5d0ea5079bfcc331603b4d03291b45b93fd Mon Sep 17 00:00:00 2001 From: Ryan D McGuire Date: Mon, 16 Dec 2024 09:44:21 -0500 Subject: [PATCH] Add CI --- .gitea/workflows/ci.yml | 55 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 .gitea/workflows/ci.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml new file mode 100644 index 0000000..0c01c51 --- /dev/null +++ b/.gitea/workflows/ci.yml @@ -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