v0.2.1 #11
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: Master-CI | |
on: | |
release: | |
types: [published] | |
push: | |
tags: | |
- v.** | |
branches: [ "master" ] | |
pull_request_target: | |
branches: [ "master" ] | |
env: | |
PYTHON_VERSION: 3.10.14 | |
JAVA_VERSION: 8.0.412+8 | |
RUST_VERSION: 1.60.0 | |
CC_VERSION: 11 | |
jobs: | |
test-app-job: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Golang version | |
run: echo -n "GO_VERSION=$(grep go go.mod | head -n1 | cut -d ' ' -f 2 | tr -d '\n')" >> $GITHUB_ENV | |
- name: Setup Golang | |
uses: actions/setup-go@v5.0.1 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Setup Python | |
uses: actions/setup-python@v5.1.0 | |
with: | |
python-version: ${{ env.PYTHON_VERSION }} | |
- name: Setup Java | |
uses: actions/setup-java@v4.2.1 | |
with: | |
java-version: ${{ env.JAVA_VERSION }} | |
distribution: temurin | |
- name: Setup CC | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gcc-${{ env.CC_VERSION }} g++-${{ env.CC_VERSION }} | |
- name: Setup Rustc | |
run: sudo apt-get install -y rustc # TODO it need to fix to specific version rustc, but compile one wasting too much time X(. | |
- name: Test code | |
run: | | |
sudo go mod tidy | |
sudo make unit-test | |
build-release-app-image-job: | |
needs: test-app-job | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get previous tag | |
id: prev_tag | |
run: echo "::set-output name=tag::$(git describe --tags --abbrev=0 HEAD^1 | sed 's/^v//')" | |
- name: Get current tag | |
id: curr_tag | |
run: echo "::set-output name=tag::$(git describe --tags --abbrev=0 HEAD | sed 's/^v//')" | |
- name: Get Imagetag | |
env: | |
image_owner: msqt | |
image_name: sb-judger | |
run: | | |
echo "image_whole_tag=none" >> $GITHUB_ENV | |
if [ "${{ steps.prev_tag.outputs.tag }}" != "${{ steps.curr_tag.outputs.tag }}" ]; then | |
echo "Tag has changed from ${{ steps.prev_tag.outputs.tag }} to ${{ steps.curr_tag.outputs.tag }}" | |
echo "image_whole_tag=$image_owner/$image_name:latest,$image_owner/$image_name:${{ steps.curr_tag.outputs.tag }}" >> $GITHUB_ENV | |
else | |
echo "Tag has not changed" | |
fi | |
echo "$image_whole_tag" | |
- name: Set up QEMU | |
if: ${{ env.image_whole_tag != 'none' }} | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
if: ${{ env.image_whole_tag != 'none' }} | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to Docker Hub | |
if: ${{ env.image_whole_tag != 'none' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Make Rootfs Before Build Image | |
if: ${{ env.image_whole_tag != 'none' }} | |
run: ROOTFS_IMAGE_TAG=latest make rootfs | |
- name: Build and push | |
if: ${{ env.image_whole_tag != 'none' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: . | |
file: build/Dockerfile | |
tags: ${{ env.image_whole_tag }} | |
platforms: linux/amd64,linux/arm64 | |
push: true |