fix github action docker #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
# This workflow will build a package using Maven and then publish it to GitHub packages when a release is created | |
# For more information see: https://github.com/actions/setup-java/blob/main/docs/advanced-usage.md#apache-maven-with-a-settings-path | |
name: Push Release | |
# 配置触发事件为标签为v开头的推送 | |
on: | |
push: | |
tags: | |
- v* | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
discussions: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set env | |
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | |
- name: ReleaseVersion | |
run: | | |
echo ${{ env.RELEASE_VERSION }} | |
- name: 建立JDK17运行环境 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml | |
settings-path: ${{ github.workspace }} # location for the settings.xml file | |
- name: 构建Maven项目 | |
run: mvn -B package --file pom.xml | |
# 构建前端 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- uses: pnpm/action-setup@v2 | |
name: Install pnpm | |
id: pnpm-install | |
with: | |
version: 8.6.10 | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: 初始化前端子项目 | |
run: git submodule init && git submodule update --init --recursive | |
- name: 安装前端依赖 | |
run: | | |
cd autoplan-front && pnpm install --no-frozen-lockfile | |
env: | |
VALIDATE_ALL_CODEBASE: false | |
DEFAULT_BRANCH: main | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: 构建前端 | |
run: cd autoplan-front && pnpm run build | |
- run: mkdir build && mkdir build/Linux_x64 && mkdir build/Linux_aarch64 && mkdir build/Windows_x64 | |
- run: wget https://corretto.aws/downloads/latest/amazon-corretto-17-x64-linux-jdk.tar.gz && tar -zxvf amazon-corretto-17-x64-linux-jdk.tar.gz | |
- run: find . -type d -name 'amazon-corretto-17*linux-x64' -exec cp -r {} build/Linux_x64/jdk \; | |
- run: wget https://corretto.aws/downloads/latest/amazon-corretto-17-aarch64-linux-jdk.tar.gz && tar -zxvf amazon-corretto-17-aarch64-linux-jdk.tar.gz | |
- run: find . -type d -name 'amazon-corretto-17*linux-aarch64' -exec cp -r {} build/Linux_aarch64/jdk \; | |
- run: wget https://corretto.aws/downloads/latest/amazon-corretto-17-x64-windows-jdk.zip && unzip amazon-corretto-17-x64-windows-jdk.zip -d amazon-corretto-17-x64-windows-jdk | |
- run: find ./amazon-corretto-17-x64-windows-jdk -maxdepth 1 -type d -name 'jdk17*' -exec cp -r {} build/Windows_x64/jdk \; | |
- run: cp target/auto_plan.jar build/Linux_x64 && cp target/auto_plan.jar build/Linux_aarch64 && cp target/auto_plan.jar build/Windows_x64 | |
- run: cp script/start.sh build/Linux_x64 && cp script/start.sh build/Linux_aarch64 && cp script/start.bat build/Windows_x64 | |
- run: cp docs/application-example.yml build/Linux_x64 && cp docs/application-example.yml build/Linux_aarch64 && cp docs/application-example.yml build/Windows_x64 | |
- run: tar -czvf build/auto_plan_linux_x64.tar.gz build/Linux_x64/ | |
- run: tar -czvf build/auto_plan_linux_aarch64.tar.gz build/Linux_aarch64/ | |
- run: zip -r build/auto_plan_windows_x64.zip build/Windows_x64/ | |
- run: zip -r build/autoplan_front.zip autoplan-front/dist/ | |
- run: cp target/auto_plan.jar build | |
- run: cp docs/application-example.yml build | |
# - name: 获取 Maven pom.xml中 version版本环境变量 | |
# run: echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV | |
# 上传文件并发布 Release | |
- name: Upload Release | |
uses: softprops/action-gh-release@v1 | |
if: startsWith(github.ref, 'refs/tags/') | |
with: | |
name: "Release ${{ env.RELEASE_VERSION }}" | |
tag_name: ${{ env.RELEASE_VERSION }} | |
files: | | |
build/auto_plan_linux_x64.tar.gz | |
build/auto_plan_linux_aarch64.tar.gz | |
build/auto_plan_windows_x64.zip | |
build/auto_plan.jar | |
build/autoplan_front.zip | |
build/application-example.yml | |
# - uses: "marvinpinto/action-automatic-releases@latest" | |
# with: | |
# repo_token: "${{ secrets.GITHUB_TOKEN }}" | |
# automatic_release_tag: "${{ env.RELEASE_VERSION }}" | |
# prerelease: false | |
# title: "Release ${{ env.RELEASE_VERSION }}" | |
# files: | | |
# build/auto_plan* | |
# build/application-example.yml | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USER }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v4 | |
with: | |
images: delik8shub/streampark | |
tags: | | |
type=raw,value=latest,enable={{is_default_branch}} | |
type=ref,event=tag | |
type=ref,event=branch | |
- name: Build and push streampark | |
uses: docker/build-push-action@v3 | |
with: | |
context: . | |
file: Dockerfile | |
platforms: linux/amd64,linux/arm64/v8 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |