-
Notifications
You must be signed in to change notification settings - Fork 30
feat: add Stackit-cli support for different package managers (zypper, dnf) #909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
38a3f01
c2d604b
09ecfd4
26d6b36
3f0d5f1
c135f16
11f441e
ac73cc0
45de844
30f7304
8e28cda
8329c51
d515533
10a1811
f889c76
d57a1eb
f28a60c
75bd37b
ff61000
6a65f28
d83516d
e8a0323
84eb11f
22edfa0
356efd8
eb41856
a8449a4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,13 +17,12 @@ permissions: | |
|
|
||
| jobs: | ||
| goreleaser: | ||
| name: Release | ||
| name: Build and Release | ||
| runs-on: macOS-latest | ||
| outputs: | ||
| gpg_fingerprint: ${{ steps.import_gpg.outputs.fingerprint }} | ||
| env: | ||
| SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} | ||
| # Needed to publish new packages to our S3-hosted APT repo | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.OBJECT_STORAGE_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SECRET_ACCESS_KEY }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
@@ -61,11 +60,6 @@ jobs: | |
| APPLE_KEY_ID: ${{ secrets.APPLE_KEY_ID }} | ||
| SIGNING_CERTIFICATE_BASE64: ${{ secrets.APPLICATION_ID_CERT }} | ||
| AUTHKEY_BASE64: ${{ secrets.APPLE_API_KEY }} | ||
| # aptly version 1.6.0 results in an segmentation fault. Therefore we fall back to version 1.5.0. | ||
| # Since it is not possible to specify a version via brew command a formula was added for aptly 1.5.0 | ||
| # (source: https://github.com/Homebrew/homebrew-core/pull/202415/files) | ||
| - name: Install Aptly version 1.5.0 | ||
| run: brew install aptly.rb | ||
| - name: Install Snapcraft | ||
| uses: samuelmeuli/action-snapcraft@v3 | ||
| - name: Run GoReleaser | ||
|
|
@@ -75,9 +69,61 @@ jobs: | |
| env: | ||
| GITHUB_TOKEN: ${{ secrets.CLI_RELEASE }} | ||
| GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | ||
| - name: Upload dist artifacts | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| retention-days: 1 | ||
|
|
||
| publish-packages: | ||
| name: Publish Packages | ||
| runs-on: ubuntu-latest | ||
| needs: goreleaser | ||
| if: contains(github.ref_name, '-') == false | ||
| env: | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.OBJECT_STORAGE_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.OBJECT_STORAGE_SECRET_ACCESS_KEY }} | ||
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| GPG_PRIVATE_KEY_FINGERPRINT: ${{ needs.goreleaser.outputs.gpg_fingerprint }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Import GPG key | ||
| uses: crazy-max/ghaction-import-gpg@v6 | ||
| id: import_gpg | ||
| with: | ||
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | ||
| # aptly version 1.6.0 results in an segmentation fault. Therefore we fall back to version 1.5.0. | ||
| # Since it is not possible to specify a version via brew command a formula was added for aptly 1.5.0 | ||
| # (source: https://github.com/Homebrew/homebrew-core/pull/202415/files) | ||
| - name: Install Aptly version 1.5.0 | ||
| run: | | ||
| # Install aptly on Ubuntu | ||
| wget -O - https://www.aptly.info/pubkey.txt | sudo apt-key add - | ||
| echo "deb https://repo.aptly.info/ squeeze main" | sudo tee -a /etc/apt/sources.list.d/aptly.list | ||
| sudo apt-get update | ||
| sudo apt-get install -y aptly | ||
| - name: Install createrepo_c | ||
| run: | | ||
| # Install createrepo_c on Ubuntu | ||
| sudo apt-get update | ||
| sudo apt-get install -y createrepo-c | ||
| - name: Download dist artifacts | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: dist | ||
| path: dist/ | ||
| - name: Publish packages to APT repo | ||
| if: contains(github.ref_name, '-') == false | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this removed? |
||
| env: | ||
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| GPG_PRIVATE_KEY_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | ||
| run: ./scripts/publish-apt-packages.sh | ||
| - name: Publish packages to RPM repo | ||
| env: | ||
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| GPG_PRIVATE_KEY_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | ||
| run: ./scripts/publish-rpm-packages.sh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| name: RPM Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - testrpmworkflow | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| rpm-release: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} | ||
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| # Use test credentials - replace with your actual test bucket credentials | ||
| AWS_ACCESS_KEY_ID: ${{ secrets.TEST_OBJECT_STORAGE_ACCESS_KEY_ID }} | ||
| AWS_SECRET_ACCESS_KEY: ${{ secrets.TEST_OBJECT_STORAGE_SECRET_ACCESS_KEY }} | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Go | ||
| uses: actions/setup-go@v5 | ||
| with: | ||
| go-version-file: "go.mod" | ||
| cache: true | ||
|
|
||
| - name: Install GoReleaser | ||
| run: go install github.com/goreleaser/goreleaser/v2@latest | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please use https://github.com/goreleaser/goreleaser-action like we do in the release workflow |
||
|
|
||
| - name: Import GPG key | ||
| uses: crazy-max/ghaction-import-gpg@v6 | ||
| id: import_gpg | ||
| with: | ||
| gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} | ||
| passphrase: ${{ secrets.GPG_PASSPHRASE }} | ||
|
|
||
| - name: Build RPMs | ||
| env: | ||
| GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| NFPM_LINUX_PACKAGES_RPM_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | ||
| run: ./release-rpm.sh | ||
|
|
||
| - name: Install createrepo_c | ||
| run: sudo apt-get update && sudo apt-get install -y createrepo-c | ||
|
|
||
| - name: Install AWS CLI | ||
| uses: unfor19/install-aws-cli-action@v1 | ||
| with: | ||
| version: 2 | ||
|
|
||
| - name: Test AWS credentials | ||
| run: | | ||
| echo "Testing AWS credentials with test bucket..." | ||
| aws s3 ls s3://distribution-test/ --endpoint-url https://object.storage.eu01.onstackit.cloud | ||
| echo "✅ AWS credentials work!" | ||
| - name: Publish RPM repo | ||
| env: | ||
| GPG_PRIVATE_KEY_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }} | ||
| run: ./publish-rpm-repo.sh | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| version: 2 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my understanding: This will be added/merged later to the .goreleaser.yaml, right? |
||
|
|
||
| before: | ||
| hooks: | ||
| - go mod tidy | ||
|
|
||
| builds: | ||
| - id: linux-builds | ||
| env: | ||
| - CGO_ENABLED=0 | ||
| goos: | ||
| - linux | ||
| goarch: | ||
| - amd64 | ||
| - arm64 | ||
| binary: "stackit" | ||
| ldflags: | ||
| - -s -w | ||
| - -X github.com/stackitcloud/stackit-cli/internal/cmd.Version={{.Version}} | ||
| - -X github.com/stackitcloud/stackit-cli/internal/cmd.Commit={{.Commit}} | ||
| - -X github.com/stackitcloud/stackit-cli/internal/cmd.Date={{.Date}} | ||
|
|
||
| archives: [] # No archives, just RPMs | ||
|
|
||
| nfpms: | ||
| - id: linux_packages | ||
| ids: | ||
| - linux-builds | ||
| package_name: stackit | ||
| vendor: STACKIT | ||
| homepage: https://github.com/stackitcloud/stackit-cli | ||
| maintainer: STACKIT Developer Tools Team <developer-tools@stackit.cloud> | ||
| description: A command-line interface to manage STACKIT resources. | ||
| license: Apache 2.0 | ||
| formats: | ||
| - rpm | ||
| rpm: | ||
| signature: | ||
| key_file: "{{ .Env.GPG_KEY_PATH }}" | ||
| contents: | ||
| - src: LICENSE.md | ||
| dst: LICENSE.md | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| RPM_OUTPUT_DIR="dist" | ||
| TEMP_DIR=$(mktemp -d) | ||
| GPG_PRIVATE_KEY_FINGERPRINT="${GPG_PRIVATE_KEY_FINGERPRINT:?Set GPG_PRIVATE_KEY_FINGERPRINT}" | ||
| GPG_PASSPHRASE="${GPG_PASSPHRASE:?Set GPG_PASSPHRASE}" | ||
| AWS_ACCESS_KEY_ID="${AWS_ACCESS_KEY_ID:?Set AWS_ACCESS_KEY_ID}" | ||
| AWS_SECRET_ACCESS_KEY="${AWS_SECRET_ACCESS_KEY:?Set AWS_SECRET_ACCESS_KEY}" | ||
|
|
||
| # Test environment S3 bucket | ||
| S3_BUCKET="distribution-test" | ||
| S3_ENDPOINT="https://object.storage.eu01.onstackit.cloud" | ||
| RPM_REPO_PATH="rpm/cli" | ||
|
|
||
| echo ">>> Preparing RPM repository structure..." | ||
| mkdir -p "$TEMP_DIR/rpm-repo/RPMS" | ||
|
|
||
| echo ">>> Copying built RPMs..." | ||
| cp "$RPM_OUTPUT_DIR"/*.rpm "$TEMP_DIR/rpm-repo/RPMS/" | ||
|
|
||
| echo ">>> Creating RPM repository metadata..." | ||
| createrepo_c "$TEMP_DIR/rpm-repo" | ||
|
|
||
| echo ">>> Signing repository metadata..." | ||
| gpg --batch --yes --pinentry-mode loopback \ | ||
| --local-user="$GPG_PRIVATE_KEY_FINGERPRINT" \ | ||
| --passphrase="$GPG_PASSPHRASE" \ | ||
| --detach-sign --armor "$TEMP_DIR/rpm-repo/repodata/repomd.xml" | ||
|
|
||
| echo ">>> Uploading to test bucket..." | ||
| aws s3 sync "$TEMP_DIR/rpm-repo/" "s3://$S3_BUCKET/$RPM_REPO_PATH/" \ | ||
| --endpoint-url "$S3_ENDPOINT" \ | ||
| --delete | ||
|
|
||
| rm -rf "$TEMP_DIR" | ||
| echo ">>> RPM repo published to test bucket: $S3_BUCKET/$RPM_REPO_PATH" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| # Create temporary GPG key file | ||
| TEMP_KEY_FILE=$(mktemp) | ||
| echo "$GPG_PRIVATE_KEY" > "$TEMP_KEY_FILE" | ||
|
|
||
| # Import key into GPG keyring | ||
| gpg --batch --import "$TEMP_KEY_FILE" | ||
|
|
||
| # Set environment variables for GoReleaser | ||
| export GPG_KEY_PATH="$TEMP_KEY_FILE" | ||
| export NFPM_LINUX_PACKAGES_RPM_PASSPHRASE="$GPG_PASSPHRASE" | ||
|
|
||
| goreleaser release --clean --config goreleaser.rpm.yaml --snapshot | ||
|
|
||
| # Clean up | ||
| rm -f "$TEMP_KEY_FILE" | ||
|
|
||
| echo "RPM build complete. Find RPMs in ./dist/" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are installing this on ubuntu it seems to be that this is not version 1.5.0 anymore. Does this work on ubuntu so was the mentioned isse with aptly version 1.6.0 only an issue on mac?
If so, then the added brew formula can be removed and of course this note as well.