ci: developing release build #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: ci | |
on: | |
push: | |
release: | |
types: [published] | |
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: find . -type d | |
- 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 release" | |
exit 1 | |
fi | |
mv proto-include go-datatrails-common-api-proto | |
tar -czf go-datatrails-common-api-proto.tar.gz go-datatrails-common-api-proto | |
gh release upload $TAG go-datatrails-common-api-proto.tar.gz | |
# 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" |