Skip to content

ci: developing release job #19

ci: developing release job

ci: developing release job #19

Workflow file for this run

name: ci
on: [release]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup go-task
run: |
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d
echo "${PWD}/bin" >> $GITHUB_PATH
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: '1.21.x'
- name: Setup protobuf
uses: arduino/setup-protoc@v2
with:
version: "24.3"
- name: all ci steps
run: |
# Note: it is by design that we don't use the builder
task apis:bootstrap
task apis:generate
task apis:export
- uses: actions/upload-artifact@v3
with:
name: go-datatrails-common-api-proto
# both datatrails-common-api protos & upstream ones under a single
# -I dir compatible location
path: exported/proto-include
# disabled until protos work
#- uses: actions/upload-artifact@v3
# with:
# name: go-datatrails-common-api-swagger
# path: exported/swagger
#- uses: actions/upload-artifact@v3
# with:
# name: go-datatrails-common-api-gen
# path: exported/datatrails-common-api-gen
release:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'release' }}
needs: build
steps:
- uses: actions/download-artifact@v3
with:
name: go-datatrails-common-api-proto
path: exported/proto-include
- name: show files
working-directory: exported/proto-include
run: ls -R
- name: Upload proto files
working-directory: exported
run: |
TAG="$(echo "${GITHUB_REF}" | grep tags | grep -o "[^/]*$" || true)"
if [ -z "$TAG" ]; then
echo "::error ::This is not a tagged push"
exit 1
fi
AUTH_HEADER="Authorization: token ${GITHUB_TOKEN}"
RELEASE_ID=$TAG
# echo "Verifying release"
# HTTP_RESPONSE=$(curl --write-out "HTTPSTATUS:%{http_code}" \
# -sSL \
# -H "${AUTH_HEADER}" \
# "https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_ID}")
# HTTP_STATUS=$(echo "$HTTP_RESPONSE" | tr -d '\n' | sed -e 's/.*HTTPSTATUS://')
# if [[ "$HTTP_STATUS" -ne 200 ]]; then
# echo "::error ::Release is missing"
# exit 1
# fi
path=proto-include
if [[ ! -d $path ]]; then exit 1; fi
ghr -u "${GITHUB_REPOSITORY%/*}" -r "${GITHUB_REPOSITORY#*/}" "${GITHUB_REF#refs/tags/}" "${path}"
echo "::debug ::Uploaded $path"