summaryrefslogtreecommitdiff
path: root/.github/workflows/publish.yml
blob: e2b095503c876a5b8e5d9a65011969531187928c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Workflow for publishing the artifacts once a GitHub release is published
name: Publish

on:
  release:
    types: [published]

jobs:
  push-simulator:
    name: Push Simulator to DockerHub
    runs-on: ubuntu-22.04
    steps:
      - name: Prepare
        id: prep
        run: |
          DOCKER_IMAGE=ghcr.io/atlarge-research/opendc
          VERSION=3.0-SNAPSHOT
          if [[ $GITHUB_REF == refs/tags/v* ]]; then
            VERSION=${GITHUB_REF#refs/tags/v}
          fi
          echo "tags=${DOCKER_IMAGE}:${VERSION}" >> $GITHUB_OUTPUT
      - name: Login to DockerHub
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Push to Docker Hub
        uses: docker/build-push-action@v5
        with:
          push: true
          file: opendc-web/opendc-web-runner/Dockerfile
          tags: ${{ steps.prep.outputs.tags }}
  push-api:
    name: Push API to DockerHub
    runs-on: ubuntu-22.04
    steps:
      - name: Prepare
        id: prep
        run: |
          DOCKER_IMAGE=ghcr.io/atlarge-research/opendc-web-api
          VERSION=3.0-SNAPSHOT
          if [[ $GITHUB_REF == refs/tags/v* ]]; then
            VERSION=${GITHUB_REF#refs/tags/v}
          fi
          echo "tags=${DOCKER_IMAGE}:${VERSION}" >> $GITHUB_OUTPUT
      - name: Login to DockerHub
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Push to Docker Hub
        uses: docker/build-push-action@v5
        with:
          push: true
          file: opendc-web/opendc-web-server/Dockerfile
          tags: ${{ steps.prep.outputs.tags }}
  push-ui:
    name: Push UI to DockerHub
    runs-on: ubuntu-22.04
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Prepare
        id: prep
        run: |
          DOCKER_IMAGE=ghcr.io/atlarge-research/opendc-web-ui
          VERSION=3.0-SNAPSHOT
          if [[ $GITHUB_REF == refs/tags/v* ]]; then
            VERSION=${GITHUB_REF#refs/tags/v}
          fi
          echo "tags=${DOCKER_IMAGE}:${VERSION}" >> $GITHUB_OUTPUT
      - name: Login to DockerHub
        uses: docker/login-action@v3
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
      - name: Push to Docker Hub
        uses: docker/build-push-action@v5
        with:
          push: true
          context: opendc-web/opendc-web-ui
          tags: ${{ steps.prep.outputs.tags }}
  publish-maven-central:
    name: Publish to Maven Central
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4
      - name: Validate Gradle wrapper
        uses: gradle/wrapper-validation-action@v1
      - name: Set up JDK
        uses: actions/setup-java@v3
        with:
          distribution: 'zulu'
          java-version: 19
      - name: Prepare
        id: prep
        run: |
          VERSION=3.0-SNAPSHOT
          if [[ $GITHUB_REF == refs/tags/v* ]]; then
            VERSION=${GITHUB_REF#refs/tags/v}
          fi
          echo "version=${VERSION}" >> $GITHUB_OUTPUT
      - name: Publish with Gradle
        uses: gradle/gradle-build-action@v2
        with:
          arguments: publish -Pversion="${{ steps.prep.outputs.version }}"
        env:
          ORG_GRADLE_PROJECT_signingKey: ${{ secrets.GPG_PRIVATE_KEY }}
          ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.GPG_PASSPHRASE }}
          ORG_GRADLE_PROJECT_ossrhUsername: ${{ secrets.OSSRH_USERNAME }}
          ORG_GRADLE_PROJECT_ossrhPassword: ${{ secrets.OSSRH_PASSWORD }}