-
Notifications
You must be signed in to change notification settings - Fork 152
feat: add support for linux distribution packaging #2478
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
Draft
Codelax
wants to merge
8
commits into
scaleway:master
Choose a base branch
from
Codelax:packaging
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1454b46
ci: add deb and rpm packaging
Codelax 74fd5ec
add deb specs and rules in makefile
Codelax c45bb0f
add debian symlink creation to deb-setup
Codelax 77a92d7
fix deb build order of execution and accept auto install
Codelax d593bfd
deb: sign package and set version
Codelax b5b0662
ci(deb): fetch version, import gpg key, package deb
Codelax 0d73b1b
deb: add metadata to binary build
Codelax 84b84f1
rpm: add metadata to binary build
Codelax 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 hidden or 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 hidden or 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,61 @@ | ||
SHELL=bash | ||
|
||
rpm-setup: | ||
sudo dnf groupinstall "RPM Development Tools" -y | ||
sudo dnf install copr-cli -y | ||
rpmdev-setuptree | ||
sudo dnf install jq -y | ||
|
||
template-rpm-spec: require-version | ||
sed s/\%\{version_\}/${VERSION}/g specs/rpm/scaleway-cli.tmpl.spec > specs/rpm/scaleway-cli.spec | ||
RELEASE_JSON="$$(curl https://api.github.com/repos/scaleway/scaleway-cli/releases/tags/v${VERSION})"; \ | ||
DATE=$$(date -d "$$(echo $${RELEASE_JSON} | jq ."created_at" -r)" "+%a %b %d %Y") ; \ | ||
CHANGELOG="$$(echo $${RELEASE_JSON} | jq ."body" -r | grep '^*' | sed s/^\*/-/g)"; \ | ||
echo "* $${DATE} Scaleway Devtools <[email protected]> - ${VERSION}" >> specs/rpm/scaleway-cli.spec; \ | ||
echo "$${CHANGELOG}" >> specs/rpm/scaleway-cli.spec | ||
|
||
srpm-build: require-version template-rpm-spec | ||
sudo dnf builddep specs/rpm/scaleway-cli.spec -y | ||
spectool -g -R specs/rpm/scaleway-cli.spec --define "version_ ${VERSION}" | ||
rpmbuild -ba specs/rpm/scaleway-cli.spec --define "version_ ${VERSION}" | ||
|
||
rpm-build: srpm-build | ||
cd ~/rpmbuild/ | ||
rpmbuild -bs | ||
|
||
template-deb-setup: | ||
apt install curl jq -y | ||
|
||
template-deb: template-deb-setup require-version | ||
RELEASE_JSON="$$(curl https://api.github.com/repos/scaleway/scaleway-cli/releases/tags/v${VERSION})"; \ | ||
CHANGELOG="$$(echo $${RELEASE_JSON} | jq ."body" -r | grep '^*' | sed s/^\*/\ \ \*/g)"; \ | ||
DATE=$$(date -d "$$(echo $${RELEASE_JSON} | jq ."created_at" -r)" -R) ; \ | ||
echo -e "scw (${VERSION}) focal; urgency=medium\n" > specs/deb/changelog; \ | ||
echo "$${CHANGELOG}" >> specs/deb/changelog; \ | ||
echo -e "\n -- Scaleway Devtools <[email protected]> $${DATE}" >> specs/deb/changelog | ||
|
||
deb-setup: | ||
apt install devscripts equivs -y | ||
ln -fs specs/deb debian | ||
mk-build-deps --install debian/control -t "apt-get -o Debug::pkgProblemResolver=yes --no-install-recommends -y" | ||
go mod vendor | ||
|
||
deb-source-build: require-version template-deb deb-setup | ||
debuild -S -us -uc | ||
|
||
deb-source-sign: require-version | ||
echo '$(value GPG_PASSPHRASE)' > /tmp/key | ||
debsign -k524A68BAB1A91B2F74DCEC3B31F9FBCA5BD8707C --re-sign -p"gpg --pinentry-mode=loopback --passphrase-file /tmp/key" ../scw_${VERSION}.dsc ../scw_${VERSION}_source.changes | ||
rm /tmp/key | ||
|
||
deb-source: deb-source-build deb-source-sign | ||
|
||
deb-build: | ||
debuild -b -us -uc | ||
|
||
require-version: | ||
ifndef VERSION | ||
$(error VERSION is undefined) | ||
endif | ||
|
||
.PHONY: rpm-setup rpm-build srpm-build |
This file contains hidden or 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 hidden or 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 @@ | ||
## File should be updated by |
This file contains hidden or 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,13 @@ | ||
Source: scw | ||
Homepage: https://www.scaleway.com/ | ||
Maintainer: Scaleway Devtools <[email protected]> | ||
Rules-Requires-Root: no | ||
Build-Depends: debhelper-compat (= 13), | ||
dh-golang, | ||
golang-any, | ||
|
||
Package: scw | ||
Architecture: all | ||
Description: Scaleway CLI | ||
XS-Go-Import-Path: github.com/scaleway/scaleway-cli/v2/cmd/scw | ||
Version: ${VERSION} |
This file contains hidden or 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/make -f | ||
|
||
export DH_GOPKG := github.com/scaleway/scaleway-cli/v2 | ||
export DH_GOLANG_BUILDPKG := ${DH_GOPKG}/cmd/scw | ||
|
||
VERSION := $(shell dpkg-parsechangelog -SVersion) | ||
SOURCE_DATE_EPOCH := $(shell git log -1 --pretty=%ct) | ||
DATE := $(shell date --date="@${SOURCE_DATE_EPOCH}" -u '+%Y-%m-%dT%H:%M:%SZ') | ||
GIT_BRANCH := $(shell git symbolic-ref -q --short HEAD || echo HEAD) | ||
GIT_COMMIT := $(shell git rev-parse --short HEAD) | ||
|
||
%: | ||
dh $@ --builddirectory=_build | ||
|
||
override_dh_auto_install: | ||
dh_auto_install -- --no-source | ||
|
||
override_dh_auto_build: | ||
dh_auto_build -- -ldflags "-w -extldflags -static -X main.Version=${VERSION} -X main.BuildDate=${DATE} -X main.GitBranch=${GIT_BRANCH} -X main.GitCommit=${GIT_COMMIT}" |
This file contains hidden or 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 @@ | ||
scaleway-cli.spec |
This file contains hidden or 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,45 @@ | ||
Name: scw | ||
Version: %{version_} | ||
Release: 1%{?dist} | ||
Summary: Scaleway CLI | ||
|
||
License: Apache License 2.0 | ||
URL: https://github.com/scaleway/scaleway-cli | ||
Source0: https://github.com/scaleway/scaleway-cli/archive/refs/tags/v%{version}.tar.gz | ||
|
||
%if 0%{?suse_version} | ||
BuildRequires: go git | ||
%else | ||
BuildRequires: golang git | ||
%endif | ||
|
||
Provides: %{name} = %{version} | ||
|
||
%description | ||
Scaleway CLI | ||
|
||
%global debug_package %{nil} | ||
|
||
%prep | ||
%autosetup -n scaleway-cli-%{version} | ||
|
||
%define build_epoch %(git log -1 --pretty="%%ct") | ||
%define build_date %(date --date="@%{build_epoch}" -u +"%%Y-%%m-%%dT%%H:%%M:%%SZ") | ||
%define git_branch %(git symbolic-ref -q --short HEAD || echo HEAD) | ||
%define git_commit %(git rev-parse --short HEAD) | ||
|
||
%build | ||
export CGO_ENABLED=0 | ||
LDFLAGS="-w -extldflags -static -X main.Version=%{version} -X main.BuildDate=%{build_date} -X main.GitBranch=%{git_branch} -X main.GitCommit=%{git_commit}" | ||
GOPROXY=direct GOOS=linux GOARCH=amd64 go build -ldflags "${LDFLAGS}" -o %{name} cmd/scw/main.go | ||
|
||
|
||
%install | ||
install -Dpm 0755 %{name} %{buildroot}%{_bindir}/%{name} | ||
|
||
|
||
%files | ||
%{_bindir}/%{name} | ||
|
||
|
||
%changelog |
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.
Why not
scaleway-cli
to distringuish fromscaleway-ecosystem
?