Skip to content

ci: fix gradle build #3

ci: fix gradle build

ci: fix gradle build #3

Workflow file for this run

name: Build
on: [push, pull_request]
permissions:
contents: write
packages: write
jobs:
backend:
name: Backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
- name: Build
run: gradle build
- name: Artifact
uses: actions/upload-artifact@v3
with:
name: rm-monitor
path: ./build/libs
release:
name: Release
runs-on: ubuntu-latest
if: github.event_name == 'push'
needs: [ backend ]
outputs:
new_version: ${{ steps.should_push.outputs.new_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Fetch Previous version
id: get-previous-tag
uses: actions-ecosystem/[email protected]
- name: mkdir
run: |
mkdir dist
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: rm-monitor
path: ./dist
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: yarn global add semantic-release @semantic-release/changelog && semantic-release
- name: Fetch Current version
id: get-current-tag
uses: actions-ecosystem/[email protected]
- name: Output New Version
id: should_push
run: |
old_version=${{steps.get-previous-tag.outputs.tag}}
new_version=${{steps.get-current-tag.outputs.tag }}
if [ "$old_version" != "$new_version" ]; then
echo "new_version=$new_version" >> $GITHUB_OUTPUT
else
echo "new_version=" >> $GITHUB_OUTPUT
fi
docker:
runs-on: ubuntu-latest
if: github.event_name == 'push' && needs.release.outputs.new_version != ''
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Buildx Cache
id: buildx-cache
uses: docker/setup-buildx-action@v3
with:
driver-opts: name=gha
- name: Buildx Cache Load
id: buildx-cache-load
uses: docker/setup-buildx-action@v3
with:
driver-opts: name=gha
action: load
- name: Login to Docker Hub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker Push
uses: docker/build-push-action@v5
if: github.event_name == 'push'
with:
context: .
push: true
platforms: linux/amd64
tags: |
scutrobot/rm-monitor:latest
scutrobot/rm-monitor:${{ needs.release.outputs.new_version }}
ghcr.io/scutrobot/rm-monitor:latest
ghcr.io/scutrobot/rm-monitor:${{ needs.release.outputs.new_version }}
build-args: |
VERSION=${{ needs.release.outputs.new_version }}
labels: |
org.opencontainers.image.source=https://github.com/scutrobot/rm-monitor
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.created=${{ github.event.head_commit.timestamp }}
org.opencontainers.image.version=${{ needs.release.outputs.new_version }}
org.opencontainers.image.title=rm-monitor ${{ needs.release.outputs.new_version }}
org.opencontainers.image.description="robomaster monitor"
org.opencontainers.image.licenses=AGPL-3.0
cache-from: type=gha
cache-to: type=gha,mode=max