-
-
Notifications
You must be signed in to change notification settings - Fork 0
151 lines (132 loc) · 5.01 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
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
name: Build & Release
on:
workflow_dispatch:
push:
branches:
- main
- next
paths:
- '**/src/**'
- '**/pom.xml'
- 'pom.xml'
concurrency:
group: ci-main
permissions:
contents: read
jobs:
build:
name: Build & Release
runs-on: ubuntu-latest
permissions:
# used by cycjimmy/semantic-release-action
contents: write
packages: write
# used by aws-actions/configure-aws-credentials
id-token: write
outputs:
new-release-published: ${{ steps.semantic-release.outputs.new_release_published }}
new-release-version: ${{ steps.semantic-release.outputs.new_release_version }}
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11
uses: actions/setup-java@v4.5.0
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
- name: Setup Node 20
uses: actions/setup-node@v4.1.0
with:
node-version: 20
cache: 'yarn'
cache-dependency-path: integration-tests/infrastructure/yarn.lock
- name: Setup Terraform
uses: hashicorp/setup-terraform@v3.1.2
with:
terraform_version: 1.5.7
terraform_wrapper: false
- name: Setup AWS Credentials for Infrastructure
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::956243129466:role/github-deployer
- name: Synth Infrastructure for Integration Tests
working-directory: integration-tests/infrastructure
run: |
yarn install --frozen-lockfile
yarn run synth
- id: apply-infrastructure
name: Apply Infrastructure for Integration Tests
working-directory: integration-tests/infrastructure/cdktf.out/stacks/feign-aws-sigv4-integration-tests
run: |
terraform init
terraform apply -auto-approve
echo "integration-test-role-arn=$(terraform output -raw integration-test-role-arn)" >> $GITHUB_OUTPUT
echo "api-gateway-url=$(terraform output -raw api-gateway-url)" >> $GITHUB_OUTPUT
- name: Setup AWS Credentials for Integration Tests
uses: aws-actions/configure-aws-credentials@v4.0.2
with:
aws-region: eu-central-1
role-to-assume: ${{ steps.apply-infrastructure.outputs.integration-test-role-arn }}
- id: run-tests
name: Run Tests
run: |
mvn -B -ntp clean install failsafe:integration-test failsafe:verify -DapiGatewayUrl=${{ steps.apply-infrastructure.outputs.api-gateway-url }}
- name: Setup AWS Credentials for Infrastructure
uses: aws-actions/configure-aws-credentials@v4.0.2
if: always()
with:
aws-region: eu-central-1
role-to-assume: arn:aws:iam::956243129466:role/github-deployer
- name: Destroy Infrastructure for Integration Tests
if: always()
working-directory: integration-tests/infrastructure/cdktf.out/stacks/feign-aws-sigv4-integration-tests
run: |
terraform destroy -auto-approve
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6.2.0
if: steps.run-tests.outcome == 'success'
with:
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- id: semantic-release
name: Create new release
uses: cycjimmy/semantic-release-action@v4.1.1
if: steps.run-tests.outcome == 'success'
with:
extra_plugins: |
@semantic-release/git
@semantic-release/exec
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OSSRH_GPG_SECRET_KEY_PASSWORD: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
publish-maven-central:
name: Publish to Maven Central
runs-on: ubuntu-latest
needs: build
if: needs.build.outputs.new-release-published == 'true'
steps:
- uses: actions/checkout@v4.2.2
- name: Set up JDK 11
uses: actions/setup-java@v4.5.0
with:
java-version: '11'
distribution: 'temurin'
cache: 'maven'
server-id: ossrh
server-username: MAVEN_USERNAME
server-password: MAVEN_PASSWORD
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6.2.0
with:
gpg_private_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
- name: Publish package
run: |
mvn -B -ntp versions:set -DgenerateBackupPoms=false -DnewVersion=${{ needs.build.outputs.new-release-version }}
mvn -B -ntp -Psign-with-gpg -Ppublish-ossrh clean deploy -DskipTests -Dgpg.passphrase=${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
env:
MAVEN_USERNAME: ${{ secrets.OSSRH_USERNAME }}
MAVEN_PASSWORD: ${{ secrets.OSSRH_TOKEN }}