Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
yajuhua committed Apr 6, 2024
1 parent 014c219 commit 0ab10c5
Show file tree
Hide file tree
Showing 1,132 changed files with 6,781 additions and 207,214 deletions.
97 changes: 60 additions & 37 deletions .github/workflows/build-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ name: Build And Push Latest
on: workflow_dispatch

jobs:
build-Package:
build-jar:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '8'
distribution: 'temurin'
cache: maven
- name: Build with Maven
Expand All @@ -21,17 +21,51 @@ jobs:
id: get_version
run: |
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- run: mkdir staging && cp target/*.war staging
- run: cp target/*.jar .

build-amd64:
permissions: write-all
runs-on: ubuntu-latest
steps:
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo "APP_VERSION=$(curl --silent "https://api.github.com/repos/yajuhua/podcast2/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_ENV

# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}

# 上传文件并发布 Release
- uses: "marvinpinto/action-automatic-releases@latest"
# 构建 amd64 Docker镜像
- name: Build the amd64 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:amd64
docker push yajuhua/podcast2:amd64
build-arm64:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "${{ env.RELEASE_VERSION }}"
prerelease: false
title: "v${{ env.RELEASE_VERSION }}"
files: |
staging/*.war
java-version: '8'
distribution: 'temurin'
cache: maven
arch: aarch64

# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
Expand All @@ -54,34 +88,23 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}

# 解压podcast2.war
- name: unzip podcast2.war
run: unzip staging/podcast2.war -d ./podcast2

# 构建 amd64 Docker 并推送到 Docker hub
- name: Build the amd64 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:latest
docker push yajuhua/podcast2:latest
# 构建 arm64 Docker 并推送到 Docker hub
- name: Build the arm64 Docker image
run: |
cat << EOF > Dockerfile
FROM yajuhua/podcast2-base:arm64
ADD podcast2 /opt/tomcat/tomcat8/webapps/podcast2
LABEL author.email="[email protected]" author.name="yajuhua"
EOF
docker build . --file Dockerfile --tag yajuhua/podcast2:arm64
docker push yajuhua/podcast2:arm64
# 构建 arm32v7 Docker 并推送到 Docker hub
- name: Build the arm32v7 Docker image
push-docker-hub:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: pull amd4 and arm64 docker images
run: |
docker pull yajuhua/podcast2:arm64
docker pull yajuhua/podcast2:amd64
- name: create manifest
run: |
docker manifest create yajuhua/podcast2 yajuhua/podcast2:arm64 yajuhua/podcast2:amd64
- name: push manifest
run: |
cat << EOF > Dockerfile
FROM yajuhua/podcast2-base:arm32v7
ADD podcast2 /opt/tomcat/tomcat8/webapps/podcast2
LABEL author.email="[email protected]" author.name="yajuhua"
EOF
docker build . --file Dockerfile --tag yajuhua/podcast2:arm32v7
docker push yajuhua/podcast2:arm32v7
docker manifest push yajuhua/podcast2
120 changes: 75 additions & 45 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,43 @@
# 构建测试镜像
name: Test Images
# 手动触发
name: Build And Push Latest
on: workflow_dispatch

jobs:
build-Push-Image:
build-jar:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
- name: Set up JDK 8
uses: actions/setup-java@v3
with:
java-version: '17'
java-version: '8'
distribution: 'temurin'
cache: maven

# git checkout 代码
- name: Checkout
uses: actions/checkout@v2

- name: Build with Maven
run: mvn -B package --file pom.xml

# 获取 Maven 项目版本
- name: Get Maven Project Version
id: get_version
run: |
echo "RELEASE_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout)" >> $GITHUB_ENV
- run: cp target/*.jar .

build-amd64:
permissions: write-all
runs-on: ubuntu-latest
steps:
# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1


# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo "APP_VERSION=$(curl --silent "https://api.github.com/repos/yajuhua/podcast2/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_ENV

# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
Expand All @@ -38,43 +48,63 @@ jobs:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}

# maven 打包
- name: Build with Maven
run: mvn -B package --file pom.xml

# 要将war包移动到其他位置,不然到后面就清空了
- run: mkdir staging && cp target/*.war staging

# 解压podcast2.war
- name: unzip podcast2.war
run: unzip staging/podcast2.war -d podcast2

# 构建 amd64 Docker 并推送到 Docker hub
# 构建 amd64 Docker镜像
- name: Build the amd64 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
docker push yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
# 构建 arm64 Docker 并推送到 Docker hub
- name: Build the arm64 Docker image
run: |
cat << EOF > Dockerfile
FROM yajuhua/podcast2-base:arm64
ADD podcast2 /opt/tomcat/tomcat8/webapps/podcast2
LABEL author.email="[email protected]" author.name="yajuhua"
EOF
build-arm64:
permissions: write-all
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '8'
distribution: 'temurin'
cache: maven
arch: aarch64

# 设置 QEMU, 后面 docker buildx 依赖此.
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
# 设置 Docker buildx, 方便构建 Multi platform 镜像
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

# 通过 git 命令获取当前 tag 信息, 存入环境变量 APP_VERSION
- name: Generate App Version
run: echo "APP_VERSION=$(curl --silent "https://api.github.com/repos/yajuhua/podcast2/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')" >> $GITHUB_ENV

# 登录 docker hub
- name: Login to DockerHub
uses: docker/login-action@v1
with:
# GitHub Repo => Settings => Secrets 增加 docker hub 登录密钥信息
# DOCKERHUB_USERNAME 是 docker hub 账号名.
# DOCKERHUB_TOKEN: docker hub => Account Setting => Security 创建.
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PWD }}

# 构建 amd64 Docker 并推送到 Docker hub
- name: Build the amd64 Docker image
run: |
docker build . --file Dockerfile --tag yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
docker push yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
# 构建 arm32v7 Docker 并推送到 Docker hub
- name: Build the arm32v7 Docker image
run: |
cat << EOF > Dockerfile
FROM yajuhua/podcast2-base:arm32v7
ADD podcast2 /opt/tomcat/tomcat8/webapps/podcast2
LABEL author.email="[email protected]" author.name="yajuhua"
EOF
docker build . --file Dockerfile --tag yajuhua/podcast2:arm32v7-$(date +test-%Y-%m-%d)
docker push yajuhua/podcast2:arm32v7-$(date +test-%Y-%m-%d)
push-docker-hub:
permissions: write-all
runs-on: ubuntu-latest
steps:
- name: pull amd4 and arm64 docker images
run: |
docker pull yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d)
docker pull yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
- name: create manifest
run: |
docker manifest create yajuhua/podcast2:beta-$(date +%Y-%m-%d) yajuhua/podcast2:arm64-$(date +test-%Y-%m-%d) yajuhua/podcast2:amd64-$(date +test-%Y-%m-%d)
- name: push manifest
run: |
docker manifest push yajuhua/podcast2:beta
35 changes: 34 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,34 @@
/.idea/
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
/src/test/
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

14 changes: 0 additions & 14 deletions .idea/compiler.xml

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/inspectionProfiles/Project_Default.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .idea/jarRepositories.xml

This file was deleted.

Loading

0 comments on commit 0ab10c5

Please sign in to comment.