Update main.yml #10
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: | |
workflow_dispatch: | |
push: | |
branches: | |
- "master" | |
tags: | |
- "*" | |
env: | |
BASE_IMAGE: crosslanguagesoccerframework/rcssserver | |
BASE_TAG: latest | |
jobs: | |
docker: | |
runs-on: ubuntu-latest | |
name: Build & Push Docker | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Find CMakeLists.txt version | |
id: cmake_version | |
run: | | |
cmake_version=$(grep -oP 'project\(.* VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) | |
echo "::set-output name=version::${cmake_version}" | |
- name: Check if the version tag exist git then skip | |
id: check_tag | |
run: | | |
git tag -l | grep -q "${{ steps.cmake_version.outputs.version }}" && echo "Tag already exists" && exit 1 || echo "Tag does not exist" | |
continue-on-error: true | |
- name: tag the version | |
if: steps.check_tag.outcome == 'success' | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Action" | |
git tag -a "${{ steps.cmake_version.outputs.version }}" -m "Version ${{ steps.cmake_version.outputs.version }}" | |
git push origin "${{ steps.cmake_version.outputs.version }}" | |
- name: Login to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push RCSSServer | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: ./utils/docker/Dockerfile | |
push: true | |
tags: "${{ env.BASE_IMAGE }}:latest,${{ env.BASE_IMAGE }}:ubuntu-24-${{ steps.cmake_version.outputs.version }}" | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v4 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
repository: ${{ env.BASE_IMAGE }} | |
readme-filepath: utils/docker/README.md | |
short-description: "RoboCup Soccer Simulator Server" | |
app-image: | |
runs-on: ubuntu-latest | |
name: Build AppImage | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Create release folder | |
run: | | |
mkdir -p ${{ github.workspace }}/artifact | |
- name: Find CMakeLists.txt version | |
id: cmake_version | |
run: | | |
cmake_version=$(grep -oP 'project\(.* VERSION \K[0-9]+\.[0-9]+\.[0-9]+' CMakeLists.txt) | |
echo "::set-output name=version::${cmake_version}" | |
# ------------------------------------------- Ubuntu 20.04 AppImage | |
- name: Prepare builder image for 20.04 | |
run: | | |
docker build -t builder-image:2004 -f ./utils/appimage/Dockerfile.builder-2004 . | |
- name: Build app image on 20.04 | |
run: | | |
docker run --privileged --name builder-2004 \ | |
builder-image:2004 /rcssserver/utils/appimage/build_appimage.sh | |
docker cp builder-2004:/rcssserver-x86_64.AppImage ${{ github.workspace }}/artifact/rcssserver-x86_64-${{ steps.cmake_version.outputs.version }}.AppImage | |
# ------------------------------------------- Artifact | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: rcssserver-x86_64 | |
path: ${{ github.workspace }}/artifact/* | |
retention-days: 5 | |
- name: List files in artifact directory | |
run: ls -l ${{ github.workspace }}/artifact/ | |
- name: Check if there is no release with the same tag | |
id: check_release | |
run: | | |
result=$(curl -s -o /dev/null -w "%{http_code}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} -u ${{ secrets.GITHUB_TOKEN }}) | |
echo "::set-output name=release_exists::$result" | |
# ------------------------------------------- Release | |
- name: Create Release | |
id: create_release | |
uses: ncipollo/release-action@v1 | |
if: steps.check_release.outputs.release_exists == '404' | |
with: | |
artifacts: "${{ github.workspace }}/artifact/*" | |
token: ${{ secrets.GITHUB_TOKEN }} | |
tag: "${{ steps.cmake_version.outputs.version }}" | |
release_name: "${{ steps.cmake_version.outputs.version }}" | |
release_body: "RoboCup Soccer Simulator Server" | |
draft: false | |
prerelease: false |