Skip to content

Commit 3195e49

Browse files
Modernize release workflows, sign rpm, deploy it to pkg_01 (#61)
* Modernize release uploading workflows * Copy the rpm
1 parent 65aea3a commit 3195e49

7 files changed

Lines changed: 178 additions & 83 deletions

.github/workflows/upload_release.yaml

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Build and upload GHCR container
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Upload Artifact as GitHub Release Attachment"]
6+
types: [completed]
7+
8+
jobs:
9+
upload_container:
10+
name: Upload Container
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
permissions:
14+
contents: read
15+
packages: write
16+
attestations: write
17+
id-token: write
18+
19+
steps:
20+
- uses: actions/checkout@v4
21+
with:
22+
fetch-depth: 0
23+
24+
- uses: actions/download-artifact@v4
25+
with:
26+
name: artifact
27+
run-id: ${{ github.event.workflow_run.id }}
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
path: rpm
30+
31+
- name: Lowercase repository name
32+
run: echo "REPO_LC=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV
33+
34+
- name: Extract metadata (tags, labels) for Docker
35+
id: meta
36+
uses: docker/[email protected]
37+
with:
38+
images: ghcr.io/${{ env.REPO_LC }}/app
39+
40+
- name: Login to GitHub Container Registry
41+
uses: docker/[email protected]
42+
with:
43+
registry: ghcr.io
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Build and push
48+
uses: docker/[email protected]
49+
with:
50+
context: .
51+
push: true
52+
tags: ${{ steps.meta.outputs.tags }}
53+
labels: ${{ steps.meta.outputs.labels }}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Upload Artifact as GitHub Release Attachment
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
upload:
9+
name: Upload
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: 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 Java
26+
uses: actions/setup-java@v4
27+
with:
28+
java-version: 17
29+
distribution: 'adopt'
30+
31+
- name: Prepare RPM GPG signing
32+
run: |
33+
sudo apt-get install expect pinentry-tty;
34+
printf "RPM_SIGNING_KEYNAME=%q\n" "$(echo "${{ secrets.RPM_SIGNING_PUBLIC_KEY }}" | gpg --show-keys --with-colons | awk -F':' '/uid/{print $10}')" >> $GITHUB_ENV;
35+
echo "${{ secrets.RPM_SIGNING_PRIVATE_KEY }}" | gpg --batch --import;
36+
echo "%_gpg_sign_cmd_extra_args --pinentry-mode loopback --passphrase \"%{getenv:RPM_SIGNING_PASSPHRASE}\"" >> "${HOME}/.rpmmacros";
37+
38+
- name: Build a jar and rpm for release
39+
run: mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= clean package && cd rpm/ && mvn --batch-mode -Drevision=${{ github.event.release.tag_name }} -Dsha1= -Dchangelist= -f rpm.pom.xml package
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
RPM_SIGNING_KEYNAME: ${{ env.RPM_SIGNING_KEYNAME }}
43+
RPM_SIGNING_PASSPHRASE: ${{ secrets.RPM_SIGNING_PASSPHRASE }}
44+
45+
- name: Attach rpm to release
46+
uses: softprops/action-gh-release@v2
47+
with:
48+
files: rpm/target/rpm/com.teragrep-cfe_16/RPMS/noarch/com.teragrep-cfe_16-*.rpm
49+
50+
- uses: actions/upload-artifact@v4
51+
with:
52+
name: artifact
53+
path: rpm/target/rpm/com.teragrep-cfe_16/RPMS/noarch/com.teragrep-cfe_16-*.rpm
54+
55+
- name: Update pkg_01 releases repository
56+
uses: teragrep/[email protected]
57+
with:
58+
from_repository: "${{ github.repository }}"
59+
from_version: "${{ github.event.release.tag_name }}"
60+
to_repository: "${{ github.repository_owner }}/pkg_01"
61+
deploy_key: ${{ secrets.PKG_01_DEPLOY_KEY }}
62+
files: rpm/target/rpm/com.teragrep-cfe_16/RPMS/noarch/com.teragrep-cfe_16-*.rpm
63+
gpg_public_key: "${{ secrets.RPM_SIGNING_PUBLIC_KEY }}"
64+
repo_baseurl: "${{ vars.PKG_01_CENTRAL_BASEURL }}"
65+
location_prefix: "${{ vars.PKG_01_LOCATION_PREFIX }}"
66+
env:
67+
has_deploy_key: ${{ secrets.PKG_01_DEPLOY_KEY != '' }}
68+
if: ${{ env.has_deploy_key == 'true' }}
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: 17
29+
distribution: 'adopt'
30+
31+
- name: Setup GitHub Packages
32+
uses: actions/setup-java@v4
33+
with:
34+
java-version: 17
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 }}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM rockylinux/rockylinux:9
2-
COPY rpm/target/rpm/com.teragrep-cfe_16/RPMS/noarch/com.teragrep-cfe_16-*.rpm /rpm/
2+
COPY rpm/com.teragrep-cfe_16-*.rpm /rpm/
33
RUN yum -y localinstall /rpm/*.rpm && yum clean all
44

55
COPY entrypoint.sh /entrypoint.sh

pom.xml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,6 @@
5252
<packaging>jar</packaging>
5353
<name>cfe_16</name>
5454
<description>cfe_16</description>
55-
<distributionManagement>
56-
<repository>
57-
<id>github</id>
58-
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
59-
</repository>
60-
</distributionManagement>
6155
<properties>
6256
<aspectj.version>1.9.25.1</aspectj.version>
6357
<changelist>-SNAPSHOT</changelist>
@@ -477,4 +471,16 @@
477471
</plugin>
478472
</plugins>
479473
</build>
474+
<profiles>
475+
<profile>
476+
<id>publish-github-packages</id>
477+
<distributionManagement>
478+
<repository>
479+
<id>github</id>
480+
<name>GitHub Packages</name>
481+
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
482+
</repository>
483+
</distributionManagement>
484+
</profile>
485+
</profiles>
480486
</project>

rpm/rpm.pom.xml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
<defineStatements>
8787
<defineStatement>_build_id_links none</defineStatement>
8888
</defineStatements>
89+
<keyname>${env.RPM_SIGNING_KEYNAME}</keyname>
90+
<keyPassphrase>
91+
<passphrase>${env.RPM_SIGNING_PASSPHRASE}</passphrase>
92+
</keyPassphrase>
8993
<mappings>
9094
<mapping>
9195
<directory>/opt/teragrep/${project.artifactId}/lib</directory>
@@ -124,10 +128,4 @@ exit 0;
124128
</plugin>
125129
</plugins>
126130
</build>
127-
<distributionManagement>
128-
<repository>
129-
<id>github</id>
130-
<url>https://maven.pkg.github.com/${env.GITHUB_REPOSITORY}</url>
131-
</repository>
132-
</distributionManagement>
133131
</project>

0 commit comments

Comments
 (0)