-
Notifications
You must be signed in to change notification settings - Fork 81
Tool to help creating distributions of packages #1335
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
Merged
Merged
Changes from 18 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a7f3b21
Add scripts to prepare distributions
jsoriano 6e0af0f
Merge remote-tracking branch 'origin/main' into cmd-distribution-scripts
jsoriano e70a21c
Run actions in parallel
jsoriano 10118ea
Select lite packages per version
jsoriano b31b25e
Add 8.19 and 9.1
jsoriano 0b47e15
linting
jsoriano d93fdf9
Merge remote-tracking branch 'origin/main' into cmd-distribution-scripts
jsoriano 10b90f5
Merge remote-tracking branch 'origin/main' into cmd-distribution-scripts
jsoriano 9cc14d4
Support pinned package versions
jsoriano a967daa
Reuse existing packages
jsoriano 8aa3e5b
Add Dockerfile
jsoriano 1148a75
Add sample for pinned versions
jsoriano 3ac5e33
Use ProtonMail fork of opengpg
jsoriano e6ca112
Use github.com/Masterminds/semver/v3
jsoriano 973d306
Merge remote-tracking branch 'origin/main' into cmd-distribution-scripts
jsoriano ce4573e
Merge remote-tracking branch 'origin/main' into cmd-distribution-scripts
jsoriano 468598f
Remove unused dockerfile
jsoriano ff94b0d
Merge remote-tracking branch 'origin/main' into cmd-distribution-scripts
jsoriano 5ecac86
Apply comments from review
jsoriano dcc6d5e
Add tests, fix race condition
jsoriano a4bc751
Fix tests
jsoriano 35463c9
Move cmd/distribution to its own module
jsoriano 135ac07
Merge remote-tracking branch 'origin/main' into cmd-distribution-scripts
jsoriano edcd868
Update AGENTS.md with recommendations about the use of require and as…
jsoriano e9ee6c9
Update magefile
jsoriano 002720e
Remove too specific readme section
jsoriano 27ae7af
Address some small issues
jsoriano e628e53
Fix test names
jsoriano 787984d
Apply suggestions from review
jsoriano 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| -----BEGIN PGP PUBLIC KEY BLOCK----- | ||
|
|
||
| mQENBFI3HsoBCADXDtbNJnxbPqB1vDNtCsqhe49vFYsZN9IOZsZXgp7aHjh6CJBD | ||
| A+bGFOwyhbd7at35jQjWAw1O3cfYsKAmFy+Ar3LHCMkV3oZspJACTIgCrwnkic/9 | ||
| CUliQe324qvObU2QRtP4Fl0zWcfb/S8UYzWXWIFuJqMvE9MaRY1bwUBvzoqavLGZ | ||
| j3SF1SPO+TB5QrHkrQHBsmX+Jda6d4Ylt8/t6CvMwgQNlrlzIO9WT+YN6zS+sqHd | ||
| 1YK/aY5qhoLNhp9G/HxhcSVCkLq8SStj1ZZ1S9juBPoXV1ZWNbxFNGwOh/NYGldD | ||
| 2kmBf3YgCqeLzHahsAEpvAm8TBa7Q9W21C8vABEBAAG0RUVsYXN0aWNzZWFyY2gg | ||
| KEVsYXN0aWNzZWFyY2ggU2lnbmluZyBLZXkpIDxkZXZfb3BzQGVsYXN0aWNzZWFy | ||
| Y2gub3JnPokBTgQTAQgAOAIbAwIXgBYhBEYJWsyFSFgsGiaZqdJ9ZmzYjkK0BQJk | ||
| 9vrZBQsJCAcDBRUKCQgLBRYCAwEAAh4FAAoJENJ9ZmzYjkK00hoH+wYXZKgVb3Wv | ||
| 4AA/+T1IAf7edwgajr58bEyqds6/4v6uZBneUaqahUqMXgLFRX5dBSrAS7bvE/jx | ||
| +BBQx+rpFGxSwvFegRevE1zAGVtpgkFQX0RpRcKSmksucSBxikR/dPn9XdJSEVa8 | ||
| vPcs11V+2E5tq3LEP14zJL4MkJKQF0VJl5UUmKLS7U2F/IB5aXry9UWdMTnwNntX | ||
| kl2iDaViYF4MC6xTS24uLwND2St0Jvjt+xGEwbdBVvp+UZ/kG6IGkYM5eWGPuok/ | ||
| DHvjUdwTfyO9b5xGbqn5FJ3UFOwB/nOSFXHM8rsHRT/67gHcIl8YFqSQXpIkk9D3 | ||
| dCY+KieW0ue5AQ0EUjceygEIAOSVJc3DFuf3LsmUfGpUmnCqoUm76Eqqm8xynFEG | ||
| ZpczTChkwARRtckcfa/sGv376j+jk0c0Q71Uv3MnMLPGF+w3bpu8fLiPeW/cntf1 | ||
| 8uZ6DxJvHA/oaZZ6VPjwUGSeVydiPtZfTYsceO8Dxl3gpS6nHZ9Gsnfr/kcH9/11 | ||
| Ca73HBtmGVIkOI1mZKMbANO8cewY/i7fPxShu7B0Rb3jxVNGUuiRcfRiao0gWx0U | ||
| ZGpvuHplt7loFX2cbsHFAp9WsjYEbSohb/Y0K4NkyFhL82MfbcsEwsXPhRTFgJWw | ||
| s4vpuFg/kFFlnw0NNPVP1jNJLNCsMBMEpP1A7k6MRpylNnUAEQEAAYkBNgQYAQgA | ||
| IAIbDBYhBEYJWsyFSFgsGiaZqdJ9ZmzYjkK0BQJk9vsHAAoJENJ9ZmzYjkK0hWsH | ||
| /ArKtn12HM3+41zYo9qO4rTri7+IYTjSB/JDTOusZgZLd/HCp1xQo4SI2Eur3Rtx | ||
| USMWK1LEeBzsjwDT9yVceYekrBEqUVyRMSVYj+UeZK2s4LbXm9b4jxXVtaivmkMA | ||
| jtznndrD7kmm8ak+UsZplf6p6uZS9TZ9hjwoMmw5oMaS6TZkLT4KYGWeyzHJSUBX | ||
| YikY6vssDQu4SJ07m1f4Hz81J39QOcHln5I5HTK8Rh/VUFcxNnGg9360g55wWpiF | ||
| eUTeMyoXpOtffiUhiOtbRYsmSYC0D4Fd5yJnO3n1pwnVVVsM7RAC22rc5j/Dw8dR | ||
| GIHikRcYWeXTYW7veewK5Ss= | ||
| =ftS0 | ||
| -----END PGP PUBLIC KEY BLOCK----- |
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 @@ | ||
| include ../../Makefile |
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,6 @@ | ||
| # Base address of the Package Registry | ||
| address: "https://epr.elastic.co" | ||
|
|
||
| queries: | ||
| - all: true | ||
| prerelease: true |
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,68 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
| // you may not use this file except in compliance with the Elastic License 2.0. | ||
|
|
||
| package main | ||
|
|
||
| import "fmt" | ||
|
|
||
| func Example_config_urls() { | ||
| config := config{ | ||
| Address: "http://localhost:8080", | ||
| Queries: []configQuery{ | ||
| {}, | ||
| {Prerelease: true}, | ||
| {KibanaVersion: "7.19.0"}, | ||
| {KibanaVersion: "7.19.0", Prerelease: true}, | ||
| {SpecMin: "2.3", SpecMax: "3.0"}, | ||
| }, | ||
| } | ||
|
|
||
| urls, err := config.searchURLs() | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| for u := range urls { | ||
| fmt.Println(u) | ||
| } | ||
|
|
||
| // Output: | ||
| // http://localhost:8080/search | ||
| // http://localhost:8080/search?prerelease=true | ||
| // http://localhost:8080/search?kibana.version=7.19.0 | ||
| // http://localhost:8080/search?kibana.version=7.19.0&prerelease=true | ||
| // http://localhost:8080/search?spec.max=3.0&spec.min=2.3 | ||
| } | ||
|
|
||
| func Example_config_urls_matrix() { | ||
| config := config{ | ||
| Address: "http://localhost:8080", | ||
| Matrix: []configQuery{ | ||
| {}, | ||
| {Prerelease: true}, | ||
| }, | ||
| Queries: []configQuery{ | ||
| {}, | ||
| {KibanaVersion: "7.19.0"}, | ||
| {SpecMin: "2.3", SpecMax: "3.0"}, | ||
| }, | ||
| } | ||
|
|
||
| urls, err := config.searchURLs() | ||
| if err != nil { | ||
| panic(err) | ||
| } | ||
|
|
||
| for u := range urls { | ||
| fmt.Println(u) | ||
| } | ||
|
|
||
| // Output: | ||
| // http://localhost:8080/search | ||
| // http://localhost:8080/search?kibana.version=7.19.0 | ||
| // http://localhost:8080/search?spec.max=3.0&spec.min=2.3 | ||
| // http://localhost:8080/search?prerelease=true | ||
| // http://localhost:8080/search?kibana.version=7.19.0&prerelease=true | ||
| // http://localhost:8080/search?prerelease=true&spec.max=3.0&spec.min=2.3 | ||
| } |
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,110 @@ | ||
| // Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| // or more contributor license agreements. Licensed under the Elastic License 2.0; | ||
| // you may not use this file except in compliance with the Elastic License 2.0. | ||
|
|
||
| package main | ||
|
|
||
| import ( | ||
| "bytes" | ||
| _ "embed" | ||
| "fmt" | ||
| "io" | ||
| "net/http" | ||
| "net/url" | ||
| "os" | ||
| "path" | ||
| "path/filepath" | ||
|
|
||
| "github.com/ProtonMail/go-crypto/openpgp" | ||
|
mrodm marked this conversation as resolved.
|
||
| ) | ||
|
|
||
| type downloadAction struct { | ||
| client *http.Client | ||
| keyRing openpgp.KeyRing | ||
|
|
||
| Address string `yaml:"address"` | ||
| Destination string `yaml:"destination"` | ||
| } | ||
|
|
||
| // publicKey is the public key of the key used to sign elastic artifacts. | ||
| // Downloaded from https://artifacts.elastic.co/GPG-KEY-elasticsearch | ||
| // | ||
| //go:embed GPG-KEY-elasticsearch | ||
| var publicKey []byte | ||
|
|
||
| func (a *downloadAction) init(c config) error { | ||
| a.client = &http.Client{} | ||
| if a.Address == "" { | ||
| a.Address = c.Address | ||
| } | ||
| err := os.MkdirAll(a.Destination, 0755) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to create desination directory: %w", err) | ||
| } | ||
| a.keyRing, err = openpgp.ReadArmoredKeyRing(bytes.NewReader(publicKey)) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to initialize public key: %w", err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (a *downloadAction) perform(i packageInfo) error { | ||
| if valid, _ := a.valid(i); valid { | ||
| return nil | ||
| } | ||
| if err := a.download(i.Download); err != nil { | ||
| return fmt.Errorf("failed to download package %s: %w", i.Download, err) | ||
| } | ||
| if err := a.download(i.SignaturePath); err != nil { | ||
| return fmt.Errorf("failed to download signature %s: %w", i.SignaturePath, err) | ||
| } | ||
| return nil | ||
| } | ||
|
|
||
| func (a *downloadAction) download(urlPath string) error { | ||
| p, err := url.JoinPath(a.Address, urlPath) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to build url: %w", err) | ||
| } | ||
| resp, err := a.client.Get(p) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to get %s: %w", urlPath, err) | ||
| } | ||
| defer resp.Body.Close() | ||
| if resp.StatusCode != http.StatusOK { | ||
| return fmt.Errorf("failed to get %s (status code %d)", urlPath, resp.StatusCode) | ||
| } | ||
|
|
||
| f, err := os.Create(a.destinationPath(urlPath)) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to open %s in %s: %w", path.Base(urlPath), a.Destination, err) | ||
| } | ||
| defer f.Close() | ||
|
|
||
| _, err = io.Copy(f, resp.Body) | ||
| return err | ||
| } | ||
|
|
||
| func (a *downloadAction) destinationPath(urlPath string) string { | ||
| return filepath.Join(a.Destination, path.Base(urlPath)) | ||
| } | ||
|
|
||
| func (a *downloadAction) valid(info packageInfo) (bool, error) { | ||
| signed, err := os.Open(a.destinationPath(info.Download)) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| defer signed.Close() | ||
|
|
||
| signature, err := os.Open(a.destinationPath(info.SignaturePath)) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| defer signature.Close() | ||
|
|
||
| _, err = openpgp.CheckArmoredDetachedSignature(a.keyRing, signed, signature, nil) | ||
| if err != nil { | ||
| return false, err | ||
| } | ||
| return true, nil | ||
| } | ||
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,90 @@ | ||
| # Base address of the Package Registry | ||
| address: "https://epr.elastic.co" | ||
|
|
||
| # Queries are executed with each one of the parameters of the matrix. | ||
| matrix: | ||
| - kibana.version: 7.17.26 | ||
| - kibana.version: 7.17.27 | ||
| - kibana.version: 7.17.28 | ||
| - kibana.version: 7.17.29 | ||
| - kibana.version: 8.15.4 | ||
| - kibana.version: 8.15.5 | ||
| - kibana.version: 8.15.6 | ||
| - kibana.version: 8.16.0 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.16.1 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.16.2 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.16.3 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.16.4 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.16.5 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.16.6 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.16.7 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.0 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.1 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.2 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.3 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.4 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.5 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.6 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.17.7 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.18.0 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.18.1 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.18.2 | ||
| spec.max: 3.3 | ||
| - kibana.version: 8.19.0 | ||
| spec.max: 3.4 | ||
| - kibana.version: 9.0.0 | ||
| spec.min: 2.3 | ||
| spec.max: 3.3 | ||
| - kibana.version: 9.0.1 | ||
| spec.min: 2.3 | ||
| spec.max: 3.3 | ||
| - kibana.version: 9.0.2 | ||
| spec.min: 2.3 | ||
| spec.max: 3.3 | ||
| - kibana.version: 9.1.0 | ||
| spec.min: 2.3 | ||
| spec.max: 3.4 | ||
| - spec.min: 2.3 | ||
| spec.max: 3.4 | ||
|
|
||
| # Queries to execute to discover packages. | ||
| queries: | ||
| - package: apache | ||
| - package: apm | ||
| - package: elastic_agent | ||
| - package: endpoint | ||
| - package: fleet_server | ||
| - package: linux | ||
| - package: log | ||
| - package: mysql | ||
| - package: nginx | ||
| - package: profiler_collector | ||
| - package: profiler_symbolizer | ||
| - package: security_ai_prompts | ||
| - package: security_detection_engine | ||
| - package: synthetics | ||
| - package: system | ||
| - package: windows | ||
|
|
||
| actions: | ||
| - print: | ||
| - download: | ||
| destination: ./build/distribution-lite |
Oops, something went wrong.
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 do we need a copy of Makefile from root here?
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.
To have the same release targets, though I could remove it as this is not used by now...