Publish Go API files to GitHub Release #23
Workflow file for this run
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: 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@v5 | |
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: Create output directory | |
run: mkdir -p ./api | |
- 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: | | |
# Assuming VERSION is in the format 'major.minor' | |
IFS='.' read -r MAJOR MINOR <<< "${{ env.VERSION }}" | |
# Create a Go file with major and minor constants | |
echo -e "package prism\n\n// MajorVersion - Major component of the API version\nconst MajorVersion = $MAJOR\n\n// MinorVersion - Minor component of the API version\nconst MinorVersion = $MINOR" > ./api/org/polypheny/prism/version.go | |
- name: Package Generated Files | |
run: | | |
mv -v ./api/org/polypheny/* ./ | |
rm -rf ./api | |
tar -czvf go-api-files-${{ env.VERSION }}.tar.gz ./prism | |
- 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 }} |