Skip to content

Commit 8e28cda

Browse files
committed
add: stripped down release n publish of rpm
1 parent 30f7304 commit 8e28cda

File tree

4 files changed

+142
-0
lines changed

4 files changed

+142
-0
lines changed

.github/workflows/rpm-test.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: RPM Test
2+
3+
on:
4+
push:
5+
branches:
6+
- testrpmworkflow
7+
workflow_dispatch:
8+
9+
jobs:
10+
rpm-release:
11+
runs-on: ubuntu-latest
12+
env:
13+
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
14+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
15+
GPG_PRIVATE_KEY_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }}
16+
AWS_ACCESS_KEY_ID: ${{ secrets.OBJECT_STORAGE_ACCESS_KEY_ID }}
17+
AWS_SECRET_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SECRET_ACCESS_KEY }}
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Go
23+
uses: actions/setup-go@v5
24+
with:
25+
go-version-file: "go.mod"
26+
cache: true
27+
28+
- name: Import GPG key
29+
uses: crazy-max/ghaction-import-gpg@v6
30+
with:
31+
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
32+
passphrase: ${{ secrets.GPG_PASSPHRASE }}
33+
34+
- name: Build RPMs
35+
run: ./release-rpm.sh
36+
37+
- name: Install createrepo_c
38+
run: sudo apt-get update && sudo apt-get install -y createrepo-c
39+
40+
- name: Install AWS CLI
41+
run: sudo apt-get install -y awscli
42+
43+
- name: Publish RPM repo
44+
run: ./publish-rpm-repo.sh

goreleaser.rpm.yaml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
version: 2
2+
3+
before:
4+
hooks:
5+
- go mod tidy
6+
7+
builds:
8+
- id: linux-builds
9+
env:
10+
- CGO_ENABLED=0
11+
goos:
12+
- linux
13+
goarch:
14+
- amd64
15+
- arm64
16+
binary: "stackit"
17+
main: ./cmd/stackit
18+
ldflags:
19+
- -s -w
20+
- -X github.com/stackitcloud/stackit-cli/internal/cmd.Version={{.Version}}
21+
- -X github.com/stackitcloud/stackit-cli/internal/cmd.Commit={{.Commit}}
22+
- -X github.com/stackitcloud/stackit-cli/internal/cmd.Date={{.Date}}
23+
24+
archives: [] # No archives, just RPMs
25+
26+
nfpms:
27+
- id: linux-packages
28+
ids:
29+
- linux-builds
30+
package_name: stackit
31+
vendor: STACKIT
32+
homepage: https://github.com/stackitcloud/stackit-cli
33+
maintainer: STACKIT Developer Tools Team <[email protected]>
34+
description: A command-line interface to manage STACKIT resources.
35+
license: Apache 2.0
36+
formats:
37+
- rpm
38+
rpm:
39+
signature:
40+
enabled: true
41+
key_file: "{{ .Env.GPG_PRIVATE_KEY }}"
42+
passphrase: "{{ .Env.GPG_PASSPHRASE }}"
43+
contents:
44+
- src: LICENSE.md
45+
dst: LICENSE.md

publish-rpm-repo.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
RPM_OUTPUT_DIR="dist"
6+
TEMP_DIR=$(mktemp -d)
7+
GPG_PRIVATE_KEY_FINGERPRINT="${GPG_PRIVATE_KEY_FINGERPRINT:?Set GPG_PRIVATE_KEY_FINGERPRINT}"
8+
GPG_PASSPHRASE="${GPG_PASSPHRASE:?Set GPG_PASSPHRASE}"
9+
AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:?Set AWS_ACCESS_KEY_ID}"
10+
AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:?Set AWS_SECRET_ACCESS_KEY}"
11+
12+
# Test environment S3 bucket
13+
S3_BUCKET="distribution-test"
14+
S3_ENDPOINT="https://object.storage.eu01.onstackit.cloud"
15+
RPM_REPO_PATH="rpm/cli"
16+
17+
echo ">>> Preparing RPM repository structure..."
18+
mkdir -p "$TEMP_DIR/rpm-repo/RPMS"
19+
20+
echo ">>> Copying built RPMs..."
21+
cp "$RPM_OUTPUT_DIR"/*.rpm "$TEMP_DIR/rpm-repo/RPMS/"
22+
23+
echo ">>> Creating RPM repository metadata..."
24+
createrepo_c "$TEMP_DIR/rpm-repo"
25+
26+
echo ">>> Signing repository metadata..."
27+
gpg --batch --yes --pinentry-mode loopback \
28+
--local-user="$GPG_PRIVATE_KEY_FINGERPRINT" \
29+
--passphrase="$GPG_PASSPHRASE" \
30+
--detach-sign --armor "$TEMP_DIR/rpm-repo/repodata/repomd.xml"
31+
32+
echo ">>> Uploading to test bucket..."
33+
aws s3 sync "$TEMP_DIR/rpm-repo/" "s3://$S3_BUCKET/$RPM_REPO_PATH/" \
34+
--endpoint-url "$S3_ENDPOINT" \
35+
--delete
36+
37+
rm -rf "$TEMP_DIR"
38+
echo ">>> RPM repo published to test bucket: $S3_BUCKET/$RPM_REPO_PATH"

release-rpm.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
: "${GPG_PRIVATE_KEY:?GPG_PRIVATE_KEY must be set}"
6+
: "${GPG_PASSPHRASE:?GPG_PASSPHRASE must be set}"
7+
8+
export GPG_PRIVATE_KEY
9+
export GPG_PASSPHRASE
10+
11+
gpg --batch --import <<< "$GPG_PRIVATE_KEY"
12+
13+
goreleaser release --clean --config goreleaser.rpm.yaml --skip-publish --skip-validate
14+
15+
echo "RPM build complete. Find RPMs in ./dist/"

0 commit comments

Comments
 (0)