forked from Fraunhofer-AISEC/ids-clearing-house-service
-
Notifications
You must be signed in to change notification settings - Fork 1
93 lines (83 loc) · 2.8 KB
/
release-publish.yml
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
name: Release
on:
push:
branches:
- feat/workflow-tests
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
id-token: write
outputs:
new_tag_version: ${{ steps.tag_version.outputs.new_tag_version }}
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v1
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Dry run to get the next release version
id: tag_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export NEXT_TAG_VERSION=$(npx semantic-release --dry-run | grep 'The next release version is' | sed -E 's/.* ([[:alnum:].\-]+)$/\1/')
echo "new_tag_version=${NEXT_TAG_VERSION}" >> $GITHUB_OUTPUT
- name: Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
publish-docker-images:
runs-on: ubuntu-latest
needs: release
permissions:
contents: read
packages: write
id-token: write
strategy:
matrix:
include:
- context: "ch-edc"
directory: "clearing-house-edc"
dockerfile: "launchers/connector-prod/Dockerfile"
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up JDK 17
if: ${{ matrix.context == 'ch-edc'}}
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Set version variable
if: ${{ needs.release.outputs.new_tag_version == 'ch-edc'}}
run: |
TAG=${{ github.ref_name }}
echo "VERSION=${TAG#v}" >> $GITHUB_ENV
- name: Build project
if: ${{ matrix.context == 'ch-edc'}}
run: |
cd clearing-house-edc
./gradlew clean build \
-PdefaultVersion=${VERSION} \
-Dorg.gradle.project.gitHubUserName=${{ github.actor }} \
-Dorg.gradle.project.gitHubUserPassword=${{ secrets.GITHUB_TOKEN }}
- name: Login to GitHub Container Registry
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Build Docker image
env:
DOCKER_IMAGE_TAG: ${{ needs.release.outputs.new_tag_version }}
run: |
cd ${{ matrix.directory }}
docker build -t ghcr.io/${{ github.repository }}/${{ matrix.context }}:$DOCKER_IMAGE_TAG -f ${{ matrix.dockerfile }} .
- name: Push Docker image
env:
DOCKER_IMAGE_TAG: ${{ needs.release.outputs.new_tag_version }}
run: docker push ghcr.io/${{ github.repository }}/${{ matrix.context }}:$DOCKER_IMAGE_TAG