Skip to content

Commit ebb1941

Browse files
authored
github workflows (#2)
1 parent 5425855 commit ebb1941

5 files changed

Lines changed: 222 additions & 40 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: CI
2+
3+
on: [ push ]
4+
5+
jobs:
6+
upload:
7+
name: CI
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- name: Cache Local Maven Repository
14+
uses: actions/cache@v4
15+
with:
16+
path: ~/.m2/repository
17+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
18+
19+
- name: Setup Java
20+
uses: actions/setup-java@v4
21+
with:
22+
java-version: 25
23+
distribution: 'adopt'
24+
25+
- name: Run CI
26+
run: mvn --batch-mode clean verify

.github/workflows/coverity.yaml

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
name: Coverity
2+
3+
on: push
4+
5+
jobs:
6+
verify:
7+
name: Verify Code
8+
runs-on: ubuntu-latest
9+
if: ${{ startsWith(github.repository, 'teragrep/') }}
10+
11+
env:
12+
COVERITY: coverity_tool
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Install jq
20+
run: sudo apt-get update && sudo apt-get install jq
21+
22+
- name: Get version
23+
run: printf "RELEASE_VERSION=%q\n" "$(git describe --tags)" >> $GITHUB_ENV
24+
25+
- name: Setup Maven Central
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: 25
29+
distribution: 'adopt'
30+
31+
- name: Cache Local Maven Repository
32+
uses: actions/cache@v4
33+
with:
34+
path: ~/.m2/repository
35+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
36+
37+
- name: Download Coverity distribution md5sum for cache key
38+
run: wget https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.COVERITY_TOKEN }}&project_id=${{ vars.COVERITY_PROJECT_URL_ID }}&md5=1" -O coverity_tool.md5
39+
40+
- name: Cache pull Coverity distribution, extracted
41+
id: cache-pull-coverity-distribution
42+
uses: actions/cache@v4
43+
with:
44+
path: ${{ runner.temp }}/${{ env.COVERITY }}
45+
key: ${{ runner.os }}-coverity-${{ hashFiles('coverity_tool.md5') }}
46+
47+
- name: Move coverity_tool.md5 file so it won't conflict with maven
48+
run: mv coverity_tool.md5 ${RUNNER_TEMP}/coverity_tool.md5
49+
50+
- name: Download and extract Coverity distribution if cache-miss
51+
if: steps.cache-pull-coverity-distribution.outputs.cache-hit != 'true'
52+
run: |
53+
wget --quiet https://scan.coverity.com/download/linux64 --post-data "token=${{ secrets.COVERITY_TOKEN }}&project_id=${{ vars.COVERITY_PROJECT_URL_ID }}" -O ${RUNNER_TEMP}/${{ env.COVERITY }}.tgz
54+
mkdir -p ${RUNNER_TEMP}/${{ env.COVERITY }}
55+
tar zxf ${RUNNER_TEMP}/${{ env.COVERITY }}.tgz -C ${RUNNER_TEMP}/${{ env.COVERITY }} --strip-components 1
56+
57+
- name: Compile Coverity
58+
run: |
59+
${RUNNER_TEMP}/${{ env.COVERITY }}/bin/cov-build --dir ${RUNNER_TEMP}/cov-int mvn -B -Drevision=${{ env.RELEASE_VERSION }} -Dsha1= -Dchangelist= -Dmaven.test.skip.exec=true clean verify
60+
cd ${RUNNER_TEMP} && tar czvf ${{ vars.COVERITY_PROJECT_URL_ID }}.tgz cov-int
61+
62+
- name: Wait for Coverity analysis slot
63+
run: |
64+
while true; do
65+
curl -X POST -d version=${{ env.RELEASE_VERSION }} -d description="automated upload" -d email=${{ secrets.COVERITY_EMAIL }} -d token=${{ secrets.COVERITY_TOKEN }} -d file_name="${{ vars.COVERITY_PROJECT_URL_ID }}.tgz" https://scan.coverity.com/projects/${{ vars.COVERITY_PROJECT_URL_ID }}/builds/init -o ${RUNNER_TEMP}/response;
66+
67+
if grep -q 'build submission quota' ${RUNNER_TEMP}/response; then
68+
cat ${RUNNER_TEMP}/response
69+
echo 'Giving up, submission quota met'
70+
exit 1
71+
fi;
72+
73+
if grep -q 'already in the queue' ${RUNNER_TEMP}/response; then
74+
cat ${RUNNER_TEMP}/response
75+
echo 'Waiting for 15 seconds and retrying'
76+
sleep 15
77+
else
78+
break
79+
fi
80+
done
81+
82+
- name: Prepare response url
83+
run: printf "RESPONSE_URL=%q\n" "$(jq -r '.url' ${RUNNER_TEMP}/response)" >> $GITHUB_ENV
84+
85+
- name: Upload to Coverity
86+
run: |
87+
curl -X PUT --header 'Content-Type: application/json' --upload-file ${RUNNER_TEMP}/${{ vars.COVERITY_PROJECT_URL_ID }}.tgz ${{ env.RESPONSE_URL }}
88+
89+
- name: Prepare build id
90+
run: printf "COVERITY_BUILD_ID=%q\n" "$(jq -r '.build_id' ${RUNNER_TEMP}/response)" >> $GITHUB_ENV
91+
92+
- name: Build Coverity Submit URL
93+
run: printf 'COVERITY_SUBMIT_URL=%q/%s/builds/%s/enqueue' "https://scan.coverity.com/projects" "${{ vars.COVERITY_PROJECT_URL_ID }}" "${{ env.COVERITY_BUILD_ID }}" >> $GITHUB_ENV
94+
95+
- name: Trigger Coverity analysis
96+
run: curl -X PUT -d token=${{ secrets.COVERITY_TOKEN }} ${{ env.COVERITY_SUBMIT_URL }}
97+
98+
- name: Restore coverity_tool.md5 file so caches can be generated
99+
run: mv ${RUNNER_TEMP}/coverity_tool.md5 coverity_tool.md5
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Upload Release to GitHub Packages
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
upload:
9+
name: Upload
10+
runs-on: ubuntu-latest
11+
permissions:
12+
packages: write
13+
14+
steps:
15+
- uses: actions/checkout@v4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: Cache Local Maven Repository
20+
uses: actions/cache@v4
21+
with:
22+
path: ~/.m2/repository
23+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
24+
25+
- name: Setup Signing
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: 25
29+
distribution: 'adopt'
30+
31+
- name: Setup GitHub Packages
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: 25
35+
distribution: 'adopt'
36+
37+
- name: Publish to GitHub Packages
38+
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean deploy -Ppublish-github-packages
39+
env:
40+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
name: Upload Release to Maven Central
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
upload:
9+
name: Upload
10+
runs-on: ubuntu-latest
11+
if: ${{ startsWith(github.repository, 'teragrep/') }}
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
with:
16+
fetch-depth: 0
17+
18+
- name: Cache Local Maven Repository
19+
uses: actions/cache@v4
20+
with:
21+
path: ~/.m2/repository
22+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
23+
24+
- name: Setup Signing
25+
uses: actions/setup-java@v4
26+
with:
27+
java-version: 25
28+
distribution: 'adopt'
29+
gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
30+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
31+
32+
- name: Setup Maven Central
33+
uses: actions/setup-java@v4
34+
with:
35+
java-version: 25
36+
distribution: 'adopt'
37+
38+
server-id: central-sonatype-org
39+
server-username: CENTRAL_SONATYPE_ORG_USERNAME
40+
server-password: CENTRAL_SONATYPE_ORG_PASSWORD
41+
gpg-passphrase: MAVEN_GPG_PASSPHRASE
42+
43+
- name: Publish to Maven Central
44+
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean deploy -Ppublish-maven-central
45+
env:
46+
CENTRAL_SONATYPE_ORG_USERNAME: ${{ secrets.CENTRAL_SONATYPE_ORG_USERNAME }}
47+
CENTRAL_SONATYPE_ORG_PASSWORD: ${{ secrets.CENTRAL_SONATYPE_ORG_PASSWORD }}
48+
MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}

pom.xml

Lines changed: 9 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@
121121
<goal>jar</goal>
122122
</goals>
123123
<configuration>
124-
<source>8</source>
124+
<source>25</source>
125125
<failOnError>false</failOnError>
126126
<doclint>none</doclint>
127127
<tags>
@@ -294,8 +294,8 @@
294294
<version>3.8.1</version>
295295
<configuration>
296296
<compilerArgument>-Xlint:all</compilerArgument>
297-
<source>16</source>
298-
<target>16</target>
297+
<source>25</source>
298+
<target>25</target>
299299
</configuration>
300300
</plugin>
301301
<plugin>
@@ -526,19 +526,9 @@
526526
</plugins>
527527
</build>
528528
<profiles>
529+
<!-- Required when publishing to Maven Central -->
529530
<profile>
530531
<id>publish-maven-central</id>
531-
<distributionManagement>
532-
<repository>
533-
<id>ossrh</id>
534-
<name>Central Repository OSSRH</name>
535-
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
536-
</repository>
537-
<snapshotRepository>
538-
<id>ossrh</id>
539-
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
540-
</snapshotRepository>
541-
</distributionManagement>
542532
<build>
543533
<plugins>
544534
<plugin>
@@ -550,7 +540,7 @@
550540
<publishingServerId>central-sonatype-org</publishingServerId>
551541
<tokenAuth>true</tokenAuth>
552542
<autoPublish>true</autoPublish>
553-
<waitUntil>published</waitUntil>
543+
<waitUntil>validated</waitUntil>
554544
</configuration>
555545
</plugin>
556546
<plugin>
@@ -576,39 +566,18 @@
576566
</plugins>
577567
</build>
578568
</profile>
569+
<!-- /Required when publishing to Maven Central -->
570+
<!-- Required when publishing to GitHub Packages -->
579571
<profile>
580572
<id>publish-github-packages</id>
581573
<distributionManagement>
582574
<repository>
583575
<id>github</id>
584576
<name>GitHub Packages</name>
585-
<url>https://maven.pkg.github.com/teragrep/tmt_01</url>
577+
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
586578
</repository>
587579
</distributionManagement>
588-
<build>
589-
<plugins>
590-
<plugin>
591-
<groupId>org.apache.maven.plugins</groupId>
592-
<artifactId>maven-gpg-plugin</artifactId>
593-
<version>1.6</version>
594-
<executions>
595-
<execution>
596-
<id>sign-artifacts</id>
597-
<goals>
598-
<goal>sign</goal>
599-
</goals>
600-
<phase>verify</phase>
601-
<configuration>
602-
<gpgArguments>
603-
<arg>--pinentry-mode</arg>
604-
<arg>loopback</arg>
605-
</gpgArguments>
606-
</configuration>
607-
</execution>
608-
</executions>
609-
</plugin>
610-
</plugins>
611-
</build>
612580
</profile>
581+
<!-- Required when publishing to GitHub Packages -->
613582
</profiles>
614583
</project>

0 commit comments

Comments
 (0)