-
Notifications
You must be signed in to change notification settings - Fork 0
152 lines (129 loc) · 5.94 KB
/
draft-release.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: Draft Release
on:
workflow_dispatch:
push:
branches: [ main ]
# By setting up concurrency group using github.ref, we essentially instruct github to only run one workflow at a time per branch
# With "cancel-in-progress: true" we also specify that existing/running workflows for that branch will be canceled
concurrency:
group: Release-${{github.ref}}
cancel-in-progress: true
jobs:
releaseJavaBinary:
name: Release Java Binary
runs-on: ubuntu-latest
steps:
- name: Setup Environment
shell: bash
run: |
echo "MVN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true --batch-mode --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" >> $GITHUB_ENV
- name: Fetch Sources
uses: actions/checkout@v4
- name: Setup Environment
run: |
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
- name: Build Java Executable
run: ./mvnw package $MVN_OPTS
- name: Remove Old Draft Releases
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api repos/{owner}/{repo}/releases \
--jq '.[] | select(.draft == true) | .id' \
| xargs -I '{}' gh api -X DELETE repos/{owner}/{repo}/releases/{}
# Create new release draft - which is not publicly visible and requires manual acceptance
- name: Create Draft Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv ./target/radicle-migration-tool-${{ env.VERSION }}-runner.jar \
./target/radicle-migration-tool-${{ env.VERSION }}.jar
gh release create v${{ env.VERSION }} ./target/radicle-migration-tool-${{ env.VERSION }}.jar \
--draft \
--title "v${{ env.VERSION }}" \
--generate-notes
releaseDockerImage:
name: Release Docker Image
runs-on: ubuntu-latest
steps:
- name: Fetch Sources
uses: actions/checkout@v4
- name: Setup Environment
run: |
VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MVN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true --batch-mode --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" >> $GITHUB_ENV
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
# Create the docker image
- name: Build & Push Docker Image
if: success()
env:
IMAGE_NAME: ${{ github.repository }}
IMAGE_VERSION: ${{ env.VERSION }}
REGISTRY_PASS: ${{ secrets.GITHUB_TOKEN }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_NAME: ghcr.io
run: |
set -x
echo $REGISTRY_PASS | docker login "${REGISTRY_NAME}" -u "${REGISTRY_PASS}" --password-stdin
# Changing the default driver is mandatory for multi-arch builds
docker buildx create --name multiarch --use
./mvnw package -Pdocker -DdockerImageTag=draft -DdockerImageArchs=linux/amd64,linux/arm64 -DdockerBuildOutput=type=image \
-DdockerImagePush=true -DdockerRegistry="${REGISTRY_NAME}" -DdockerPassword="${REGISTRY_PASS}" -DdockerUsername="${REGISTRY_USER}" $MVN_OPTS
releaseNativeBinaries:
needs: releaseJavaBinary
name: Release Native Binary
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
steps:
- name: Fetch Sources
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: corretto
java-version: 17
- name: Setup Environment
shell: bash
run: |
echo "MVN_OPTS=-Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true --batch-mode --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true" >> $GITHUB_ENV
MAVEN_COMMAND="$(if [ "$RUNNER_OS" == "Windows" ]; then echo "./mvnw.cmd"; else echo "./mvnw"; fi)"
VERSION=$(eval "$MAVEN_COMMAND help:evaluate -Dexpression=project.version -q -DforceStdout")
ASSET_SUFFIX="$(if [ "$RUNNER_OS" == "Windows" ]; then echo ".exe"; else echo ""; fi)"
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAVEN_COMMAND=$MAVEN_COMMAND" >> $GITHUB_ENV
echo "ASSET_SUFFIX=$ASSET_SUFFIX" >> $GITHUB_ENV
- name: Setup GraalVM
if: startsWith(matrix.os, 'macos-') || startsWith(matrix.os, 'windows-')
uses: graalvm/setup-graalvm@v1
with:
version: 'latest'
gds-token: ${{ secrets.GDS_TOKEN }}
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Build Native Executable
shell: bash
run: eval "${MAVEN_COMMAND} verify -Pnative $MVN_OPTS"
- name: Upload Native Executable To Draft Release
shell: bash
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
mv ./target/radicle-migration-tool-${{ env.VERSION }}-runner${{ env.ASSET_SUFFIX }} \
./target/radicle-migration-tool-${{ env.VERSION }}-${{ matrix.os }}${{ env.ASSET_SUFFIX }}
gh release upload v${{ env.VERSION }} \
./target/radicle-migration-tool-${{ env.VERSION }}-${{ matrix.os }}${{ env.ASSET_SUFFIX }} \
--clobber