Add go package upload

This commit is contained in:
Ryan McGuire 2024-12-16 15:51:32 -05:00
parent 3b707cced3
commit 990cfbf233

View File

@ -7,6 +7,8 @@ env:
PACKAGE_NAME: eia-api-go PACKAGE_NAME: eia-api-go
BINARY_PATH: bin BINARY_PATH: bin
BINARY_NAME: eia-client BINARY_NAME: eia-client
GO_MOD_PATH: gitea.libretechconsulting.com/50w/eia-api-go
GOPRIVATE: gitea.libretechconsulting.com/*
# DOCKER_HOST: "unix:///var/run/user/1000/docker.sock" # DOCKER_HOST: "unix:///var/run/user/1000/docker.sock"
# DOCKER_ORG: "rmcguire" # DOCKER_ORG: "rmcguire"
# DOCKER_LATEST: "latest" # DOCKER_LATEST: "latest"
@ -26,7 +28,7 @@ jobs:
- name: Build Binary - name: Build Binary
run: make all # Build the binary run: make all # Build the binary
- name: Upload Artifact to Gitea - name: Upload Client Binary to Generic Registry
env: env:
API_TOKEN: ${{ secrets.API_TOKEN }} # Replace with a Gitea token stored in repository secrets API_TOKEN: ${{ secrets.API_TOKEN }} # Replace with a Gitea token stored in repository secrets
run: | run: |
@ -40,6 +42,18 @@ jobs:
exit 1 exit 1
fi fi
- name: Generate and Upload Package to Go Registry
run: |
ZIPFILE=$( go mod download --json ${GO_MOD_PATH}@${{ github.ref_name }} | jq .Zip )
if [ $? -ne 0 ]; then
echo "Failed to generage go package archive for ${GO_MOD_PATH}@${{ github.ref_name }}"
exit 1
fi
curl -X PUT \
-H "Authorization: token ${API_TOKEN}" \
--upload-file ${ZIPFILE} \
"${GITHUB_SERVER_URL}/api/packages/${GITHUB_REPOSITORY_OWNER}/go/upload"
publish: publish:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: build # Ensure this stage runs only after 'build' is successful needs: build # Ensure this stage runs only after 'build' is successful