|
| 1 | +name: Publish images via Docker |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [ published ] |
| 6 | + |
| 7 | +env: |
| 8 | + APP_NAME: infosphere |
| 9 | + GITHUB_REGISTRY: ghcr.io |
| 10 | + APP_GITHUB_GROUP: devlive-community |
| 11 | + APP_DOCKER_GROUP: devliveorg |
| 12 | + |
| 13 | +jobs: |
| 14 | + before-compile: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + outputs: |
| 18 | + APP_VERSION: ${{ steps.apply_version.outputs.APP_VERSION }} |
| 19 | + |
| 20 | + steps: |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v3 |
| 23 | + |
| 24 | + - name: Setup java |
| 25 | + uses: actions/setup-java@v3 |
| 26 | + with: |
| 27 | + java-version: '11' |
| 28 | + distribution: 'temurin' |
| 29 | + |
| 30 | + - name: Generate app version |
| 31 | + run: echo APP_VERSION=`./mvnw -Dexec.executable='echo' -Dexec.args='${project.version}' --non-recursive exec:exec -Dorg.slf4j.simpleLogger.defaultLogLevel=WARN -Dorg.slf4j.simpleLogger.log.org.apache.maven.plugins.help=INFO | tail -1` >> "$GITHUB_OUTPUT" |
| 32 | + id: apply_version |
| 33 | + |
| 34 | + - name: Compile from source |
| 35 | + run: | |
| 36 | + chmod 755 ./mvnw |
| 37 | + ./mvnw clean install package -Dfindbugs.skip -Dgpg.skip -Dcheckstyle.skip -DskipTests=true -q |
| 38 | +
|
| 39 | + - name: Cache binary |
| 40 | + id: cache-binary |
| 41 | + uses: actions/cache@v3 |
| 42 | + env: |
| 43 | + cache-name: cache-binary |
| 44 | + with: |
| 45 | + path: | |
| 46 | + ./Dockerfile |
| 47 | + ./dist/infosphere-release.tar.gz |
| 48 | + key: ${{ runner.os }}-build-${{ env.cache-name }} |
| 49 | + restore-keys: ${{ runner.os }}-build-${{ env.cache-name }} |
| 50 | + |
| 51 | + publish-github-ghcr: |
| 52 | + runs-on: ubuntu-latest |
| 53 | + needs: |
| 54 | + - before-compile |
| 55 | + steps: |
| 56 | + - name: Get cache binary |
| 57 | + id: cache-binary |
| 58 | + uses: actions/cache@v3 |
| 59 | + env: |
| 60 | + cache-name: cache-binary |
| 61 | + with: |
| 62 | + path: | |
| 63 | + ./Dockerfile |
| 64 | + ./dist/infosphere-release.tar.gz |
| 65 | + key: ${{ runner.os }}-build-${{ env.cache-name }} |
| 66 | + restore-keys: ${{ runner.os }}-build-${{ env.cache-name }} |
| 67 | + |
| 68 | + - name: Set up QEMU |
| 69 | + uses: docker/setup-qemu-action@v1 |
| 70 | + |
| 71 | + - name: Set up Docker Build |
| 72 | + uses: docker/setup-buildx-action@v1 |
| 73 | + |
| 74 | + - name: Login |
| 75 | + uses: docker/login-action@v1 |
| 76 | + with: |
| 77 | + registry: ${{ env.GITHUB_REGISTRY }} |
| 78 | + username: qianmoq |
| 79 | + password: ${{ secrets.PACKAGES_TOKEN }} |
| 80 | + |
| 81 | + - name: Build and push |
| 82 | + uses: docker/build-push-action@v2 |
| 83 | + with: |
| 84 | + context: . |
| 85 | + push: true |
| 86 | + tags: | |
| 87 | + ${{ env.GITHUB_REGISTRY }}/${{ env.APP_GITHUB_GROUP }}/${{ env.APP_NAME }}:${{ needs.before-compile.outputs.APP_VERSION }} |
| 88 | + ${{ env.GITHUB_REGISTRY }}/${{ env.APP_GITHUB_GROUP }}/${{ env.APP_NAME }}:latest |
| 89 | +
|
| 90 | + publish-docker-hub: |
| 91 | + runs-on: ubuntu-latest |
| 92 | + needs: |
| 93 | + - before-compile |
| 94 | + steps: |
| 95 | + - name: Get cache binary |
| 96 | + id: cache-binary |
| 97 | + uses: actions/cache@v3 |
| 98 | + env: |
| 99 | + cache-name: cache-binary |
| 100 | + with: |
| 101 | + path: | |
| 102 | + ./Dockerfile |
| 103 | + ./dist/infosphere-release.tar.gz |
| 104 | + key: ${{ runner.os }}-build-${{ env.cache-name }} |
| 105 | + restore-keys: ${{ runner.os }}-build-${{ env.cache-name }} |
| 106 | + |
| 107 | + - name: Set up QEMU |
| 108 | + uses: docker/setup-qemu-action@v1 |
| 109 | + |
| 110 | + - name: Set up Docker Build |
| 111 | + uses: docker/setup-buildx-action@v1 |
| 112 | + |
| 113 | + - name: Login to DockerHub |
| 114 | + uses: docker/login-action@v1 |
| 115 | + with: |
| 116 | + username: ${{ secrets.ORG_DOCKERHUB_USERNAME }} |
| 117 | + password: ${{ secrets.ORG_DOCKERHUB_TOKEN }} |
| 118 | + |
| 119 | + - name: Build and push |
| 120 | + uses: docker/build-push-action@v2 |
| 121 | + with: |
| 122 | + context: . |
| 123 | + push: true |
| 124 | + tags: | |
| 125 | + ${{ env.APP_DOCKER_GROUP }}/${{ env.APP_NAME }}:${{ needs.before-compile.outputs.APP_VERSION }} |
| 126 | + ${{ env.APP_DOCKER_GROUP }}/${{ env.APP_NAME }}:latest |
0 commit comments