Skip to content

Build and Create AppImage #29

Build and Create AppImage

Build and Create AppImage #29

Workflow file for this run

name: Build and Create AppImage
# Define a manual trigger with input for version
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Install dependencies for protoc-gen-doc and set up Go environment
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y protobuf-compiler
# Step 3: Install protoc-gen-doc plugin
- name: Install protoc-gen-doc plugin
run: |
# Set Go modules on
export GO111MODULE=on
# Install the protoc-gen-doc plugin
go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest
# Add Go bin directory to PATH
export PATH=$PATH:$(go env GOPATH)/bin
# Step 4: Generate Markdown from the Protobuf file
- name: Generate Protobuf Documentation
run: |
# Generate markdown from .proto file
protoc --doc_out=./idl --doc_opt=markdown,protobuf.md ./idl/grpc/service.proto
# Ensure the generated markdown file is added to the repository
git add ./idl/protobuf.md
git commit -m "Update protobuf documentation"
git push
# Step 2: Pull Docker image from Docker Hub
- name: Set up Docker
uses: docker/setup-buildx-action@v2
- name: Pull Docker image
run: docker pull naderzare/ubuntu20-grpc-thrift:latest
# Step 3: Run the build.sh script inside the Docker container
- name: Build project
run: |
docker run --rm -v ${{ github.workspace }}:/workspace naderzare/ubuntu20-grpc-thrift:latest \
bash -c "pwd && ls && cd /workspace/utils && ls && chmod +x build.sh && ./build.sh && cd /workspace/utils/app-image && chmod +x create_app_images.sh && ./create_app_images.sh"
# Step 4: Extract version and changes from ChangeLog
- name: Extract version and changes from ChangeLog
id: changelog
run: |
VERSION=$(grep -oP '## \[\K[^\]]+' ChangeLog.md | head -n 1)
CHANGES=$(awk "/## \[$VERSION\]/ {flag=1; next} /^## \[/ {flag=0} flag" ChangeLog.md)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "CHANGES<<EOF" >> $GITHUB_ENV
echo "$CHANGES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
# Step 5: Get the latest release version from GitHub
- name: Get latest release version
id: get_latest_release
run: |
LATEST_RELEASE_VERSION=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "LATEST_RELEASE_VERSION=$LATEST_RELEASE_VERSION" >> $GITHUB_ENV
# Step 6: Compare the extracted version with the latest release version
- name: Compare versions
run: |
if [ "${{ env.VERSION }}" == "${{ env.LATEST_RELEASE_VERSION }}" ]; then
echo "Error: Version ${{ env.VERSION }} is the same as the latest released version."
exit 1
fi
# Step 7: Upload the tar.gz file as a release asset
- name: Create GitHub Release
uses: softprops/action-gh-release@v1
with:
files: ${{ github.workspace }}/utils/app-image/soccer-simulation-proxy.tar.gz
tag_name: ${{ env.VERSION }}
release_name: Release ${{ env.VERSION }}
name: Release ${{ env.VERSION }}
body: ${{ env.CHANGES }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}