Skip to content

Publish Go API files to GitHub Release #3

Publish Go API files to GitHub Release

Publish Go API files to GitHub Release #3

Workflow file for this run

name: Publish Go API files to GitHub Release
on:
release:
types:
- published
jobs:
publish-go:
name: Build and publish Go API files to GitHub Release
runs-on: ubuntu-latest
permissions:
contents: write
actions: write
steps:
- uses: actions/checkout@v4
- name: Set up Go environment
uses: actions/setup-go@v3
with:
go-version: '1.18' # Specify the Go version.
- name: Install Protoc Go Plugin
run: go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
- name: Add GOPATH/bin to PATH
run: echo "$GOPATH/bin" >> $GITHUB_PATH
- name: Set Version
id: version
run: |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Download and Extract Protobuf Compiler
run: |
wget https://github.com/protocolbuffers/protobuf/releases/download/v26.0/protoc-26.0-linux-x86_64.zip
unzip protoc-26.0-linux-x86_64.zip -d $HOME/protoc
- name: Generate Go files from Protobuf
run: $HOME/protoc/bin/protoc --proto_path=. --go_out=./api --go_opt=paths=source_relative org/polypheny/prism/*.proto
- name: Create Version Go file
run: echo -e "package api\n\n// Version - API version\nconst Version = \"${{ env.VERSION }}\"" > ./api/version.go
- name: Package Generated Files
run: tar -czvf go-api-files-${{ env.VERSION }}.tar.gz ./api
- name: Upload ZIP to GitHub Release
uses: softprops/action-gh-release@v2
with:
files: go-api-files-${{ env.VERSION }}.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}