-
Notifications
You must be signed in to change notification settings - Fork 19
57 lines (55 loc) · 1.95 KB
/
build.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
name: build
on:
push:
branches:
- main
tags:
- v**
pull_request:
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17
- name: Determine Version
run: |
# determine version from tag
export VERSION=$(echo "${GITHUB_REF}" | cut -d "/" -f3)
if [[ $VERSION != v* ]]
then
export VERSION=""
echo "Building version-less (master or feature branch)"
else
# make version more Java-friendly by dropping the 'v'
export VERSION=${VERSION:1:${#VERSION}}
echo "Building as ${VERSION}"
fi
# store version in GitHub environment file
echo "version=$VERSION" >> $GITHUB_ENV
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: Build ${{ env.version }}
run: ./gradlew :codyze-cli:build -x check --parallel -Pversion=${{ env.version }}
- name: Push Release Docker Image
if: startsWith(github.ref, 'refs/tags/v')
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker build -t ghcr.io/fraunhofer-aisec/codyze:latest .
docker tag ghcr.io/fraunhofer-aisec/codyze:latest ghcr.io/fraunhofer-aisec/codyze:${{ env.version }}
docker push ghcr.io/fraunhofer-aisec/codyze:${{ env.version }}
docker push ghcr.io/fraunhofer-aisec/codyze:latest
- name: Create Release
if: startsWith(github.ref, 'refs/tags/v')
uses: softprops/action-gh-release@v2
with:
name: ${{ env.version }}
generate_release_notes: true
files: codyze-cli/build/distributions/codyze-cli-${{ env.version }}.zip