|
| 1 | +name: Release |
| 2 | +on: |
| 3 | + push: |
| 4 | + tags: |
| 5 | + - v* |
| 6 | + |
| 7 | +env: |
| 8 | + REGISTRY: ghcr.io |
| 9 | + BASE_IMAGE_NAME: ghcr.io/oracle/weblogic-monitoring-exporter |
| 10 | + |
| 11 | +jobs: |
| 12 | + build: |
| 13 | + name: Build |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: "Set environmental variables" |
| 17 | + run: | |
| 18 | + VERSION=${GITHUB_REF_NAME#v} |
| 19 | + echo "VERSION=$VERSION" >> $GITHUB_ENV |
| 20 | + echo "IMAGE_NAME=${{ env.REGISTRY }}/${{ env.BASE_IMAGE_NAME }}:$VERSION" >> $GITHUB_ENV |
| 21 | + - uses: actions/checkout@v3 |
| 22 | + with: |
| 23 | + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis |
| 24 | + - name: Set up JDK |
| 25 | + uses: actions/setup-java@v3 |
| 26 | + with: |
| 27 | + distribution: 'temurin' |
| 28 | + java-version: 17 |
| 29 | + - name: Cache Maven packages |
| 30 | + uses: actions/cache@v3 |
| 31 | + with: |
| 32 | + path: ~/.m2 |
| 33 | + key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }} |
| 34 | + restore-keys: ${{ runner.os }}-m2 |
| 35 | + - name: Build |
| 36 | + env: |
| 37 | + GITHUB_TOKEN: ${{ secrets.ECNJ_GITHUB_TOKEN }} # Needed to get PR information, if any |
| 38 | + run: mvn clean package -Dtag=${{ env.VERSION }} |
| 39 | + |
| 40 | + - name: Create Draft Release |
| 41 | + id: draft-release |
| 42 | + run: | |
| 43 | + echo 'PR_URL<<EOF' >> $GITHUB_ENV |
| 44 | + gh release create ${{ env.VERSION }}\ |
| 45 | + --draft \ |
| 46 | + --generate-notes \ |
| 47 | + --title 'WebLogic Monitoring Exporter ${{ env.VERSION }}' \ |
| 48 | + --repo https://github.com/oracle/weblogic-monitoring-exporter \ |
| 49 | + wls-exporter-war/target/wls-exporter.war wls-exporter-war/target/classes/get_v${{ env.VERSION }}.sh |
| 50 | + echo 'EOF' >> $GITHUB_ENV |
| 51 | + env: |
| 52 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 53 | + |
| 54 | + - name: Log in to the Container registry |
| 55 | + uses: docker/login-action@v2 |
| 56 | + with: |
| 57 | + registry: ${{ env.REGISTRY }} |
| 58 | + username: ${{ github.actor }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Build and push Docker image |
| 62 | + uses: docker/build-push-action@v3 |
| 63 | + with: |
| 64 | + context: . |
| 65 | + push: true |
| 66 | + tags: ${{ env.IMAGE_NAME }} |
0 commit comments