-
Notifications
You must be signed in to change notification settings - Fork 258
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
Add support in for signing and publishing RPM and Deb packages to GCP Artifact Registry #1246
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
7fcbad4
Add support in for signing and publishing RPM and Deb packages to GCP…
jdoss 648e2ad
Add yaml-language-server modline to set the YAML schema to Goreleaser…
jdoss afedfdc
Update scripts/package-repo-import.sh
jdoss cc4ceb6
Update scripts/package-repo-import.sh
jdoss ee2cf66
Add missing variables.
jdoss 4db4cf9
Fix conditional for uploading packages
jdoss 6aae40e
Use goreleaser.yml@jdoss/Package_Repos for testing.
jdoss 54d3e3b
Add packages: write.
jdoss d40a6c1
Set enable-packages-upload: true.
jdoss d3ac1b7
Ignore goreleaser dist/ directory.
jdoss 1130654
Fix Debian ARMv6 and ARMv7 duplicated package names.
jdoss 082fe65
Switch back to goreleaser.yml@main.
jdoss File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
# Documentation: https://goreleaser.com/customization/ | ||
# yaml-language-server: $schema=https://goreleaser.com/static/schema-pro.json | ||
version: 2 | ||
project_name: step | ||
|
||
variables: | ||
packageName: step-cli | ||
packageRelease: 1 # Manually update release: in the nfpm section to match this value if you change this | ||
|
||
before: | ||
hooks: | ||
- go mod download | ||
|
||
after: | ||
hooks: | ||
- cmd: bash scripts/package-repo-import.sh {{ .Var.packageName }} {{ .Version }} | ||
output: true | ||
|
||
builds: | ||
- &BUILD | ||
id: default | ||
|
@@ -86,8 +96,13 @@ nfpms: | |
- &NFPM | ||
builds: | ||
- nfpm | ||
package_name: step-cli | ||
file_name_template: "{{ .PackageName }}_{{ .Version }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}{{ if .Mips }}_{{ .Mips }}{{ end }}" | ||
package_name: "{{ .Var.packageName }}" | ||
release: "1" | ||
file_name_template: >- | ||
{{- trimsuffix .ConventionalFileName .ConventionalExtension -}} | ||
{{- if and (eq .Arm "6") (eq .ConventionalExtension ".deb") }}6{{ end -}} | ||
{{- if not (eq .Amd64 "v1")}}{{ .Amd64 }}{{ end -}} | ||
{{- .ConventionalExtension -}} | ||
vendor: Smallstep Labs | ||
homepage: https://github.com/smallstep/cli | ||
maintainer: Smallstep <[email protected]> | ||
|
@@ -113,6 +128,13 @@ nfpms: | |
scripts: | ||
postinstall: scripts/postinstall.sh | ||
postremove: scripts/postremove.sh | ||
rpm: | ||
signature: | ||
key_file: "{{ .Env.GPG_PRIVATE_KEY_FILE }}" | ||
deb: | ||
signature: | ||
key_file: "{{ .Env.GPG_PRIVATE_KEY_FILE }}" | ||
type: origin | ||
- | ||
<< : *NFPM | ||
id: unversioned | ||
|
@@ -134,6 +156,13 @@ signs: | |
args: ["sign-blob", "--oidc-issuer=https://token.actions.githubusercontent.com", "--output-certificate=${certificate}", "--output-signature=${signature}", "${artifact}", "--yes"] | ||
artifacts: all | ||
|
||
publishers: | ||
- name: Google Cloud Artifact Registry | ||
ids: | ||
- packages | ||
cmd: ./scripts/package-upload.sh {{ abs .ArtifactPath }} {{ .Var.packageName }} {{ .Version }} {{ .Var.packageRelease }} | ||
disable: "{{ if .Prerelease }}true{{ end }}" | ||
|
||
snapshot: | ||
name_template: "{{ .Tag }}-next" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
: ${GCLOUD_LOCATION:=us-central1} | ||
: ${GCLOUD_RPM_REPO:=rpms} | ||
: ${GCLOUD_DEB_REPO:=debs} | ||
|
||
PACKAGE="${1}" | ||
VERSION="${2}" | ||
RELEASE="1" | ||
EPOCH="0" | ||
GORELEASER_PHASE=${GORELEASER_PHASE:-release} | ||
|
||
echo "Package: ${PACKAGE}" | ||
echo "Version: ${VERSION}" | ||
|
||
check_package() { | ||
local EXITCODE=0 | ||
local REPO="${1}" | ||
local VER="${2}" | ||
if [ ! -f /tmp/version-deleted.stamp ]; then | ||
gcloud artifacts versions list \ | ||
--repository "${REPO}" \ | ||
--location "${GCLOUD_LOCATION}" \ | ||
--package "${PACKAGE}" \ | ||
--filter "VERSION:${VER}" \ | ||
--format json 2> /dev/null \ | ||
| jq -re '.[].name?' >/dev/null 2>&1 \ | ||
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. might need to install 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. JQ comes preinstalled on the ubuntu action IIRC. |
||
|| EXITCODE=$? | ||
if [[ "${EXITCODE}" -eq 0 ]]; then | ||
echo "Package version already exists. Removing it..." | ||
gcloud artifacts versions delete \ | ||
--quiet "${VER}" \ | ||
--package "${PACKAGE}" \ | ||
--repository "${REPO}" \ | ||
--location "${GCLOUD_LOCATION}" | ||
touch /tmp/version-deleted.stamp | ||
fi | ||
fi | ||
} | ||
|
||
if [[ ${GORELEASER_PHASE} != "publish" ]]; then | ||
echo "Skipping artifact import; GORELEASER_PHASE is not 'publish'" | ||
exit 0; | ||
fi | ||
|
||
check_package "${GCLOUD_RPM_REPO}" "${EPOCH}:${VERSION}-${RELEASE}" | ||
gcloud artifacts yum import "${GCLOUD_RPM_REPO}" \ | ||
--location "${GCLOUD_LOCATION}" \ | ||
--gcs-source "gs://artifacts-outgoing/${PACKAGE}/rpm/${VERSION}/*" | ||
|
||
check_package ${GCLOUD_DEB_REPO} "${VERSION}-${RELEASE}"} | ||
gcloud artifacts apt import "${GCLOUD_DEB_REPO}" \ | ||
--location "${GCLOUD_LOCATION}" \ | ||
--gcs-source "gs://artifacts-outgoing/${PACKAGE}/deb/${VERSION}/*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
FILE="${1}" | ||
PACKAGE="${2}" | ||
VERSION="${3}" | ||
|
||
echo "Package File: ${FILE}" | ||
echo "Package: ${PACKAGE}" | ||
echo "Version: ${VERSION}" | ||
echo "Release: ${RELEASE}" | ||
echo "Location: ${GCLOUD_LOCATION}" | ||
|
||
if [ "${FILE: -4}" == ".deb" ]; then | ||
gcloud storage cp ${FILE} gs://artifacts-outgoing/${PACKAGE}/deb/${VERSION}/ | ||
else | ||
gcloud storage cp ${FILE} gs://artifacts-outgoing/${PACKAGE}/rpm/${VERSION}/ | ||
fi |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
What's the reason for not using
"{{ .Var.packageRelease }}"
in the nfpm section?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.
It will default to -1 and you only need to set that if we need to manually change the release and the nfpm section doesn't support variables.