-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/reuse-aggregation-from-ctf
- Loading branch information
Showing
48 changed files
with
605 additions
and
188 deletions.
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
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,60 @@ | ||
name: Manually retrigger the publishing of ocm-cli to other repositories | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
version: | ||
type: string | ||
description: Which version (e.g. v0.42.0) do you want to publish? | ||
required: true | ||
default: '' | ||
push-to-aur: | ||
type: boolean | ||
description: Do you want to push to the Arch Linux User Repository? | ||
required: false | ||
default: false | ||
push-to-chocolatey: | ||
type: boolean | ||
description: Do you want to push to Chocolatey? | ||
required: false | ||
default: false | ||
push-to-winget: | ||
type: boolean | ||
description: Do you want to push to Winget? | ||
required: false | ||
default: false | ||
|
||
jobs: | ||
retrigger: | ||
name: Create new "Release Publish Event" | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
id-token: write | ||
packages: write | ||
steps: | ||
- name: Generate token | ||
id: generate_token | ||
uses: tibdex/github-app-token@v2 | ||
with: | ||
app_id: ${{ secrets.OCMBOT_APP_ID }} | ||
private_key: ${{ secrets.OCMBOT_PRIV_KEY }} | ||
- name: Ensure proper version | ||
run: | | ||
curl -sSL -H "Accept: application/vnd.github+json" -H "Authorization: Bearer ${{ steps.generate_token.outputs.token }}" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/open-component-model/ocm/releases > releases.json | ||
jq -r '.[] | .tag_name' releases.json | grep -v -E '.*-rc|latest' > versions.txt | ||
if grep -Fxq '${{ github.event.inputs.version }}' versions.txt; then | ||
echo "Version (${{ github.event.inputs.version }}) found!" | ||
else | ||
echo "Version (${{ github.event.inputs.version }}) not found! This are the availble ones:" | ||
cat versions.txt | ||
exit 1 | ||
fi | ||
echo "RELEASE_VERSION=$(echo ${{ github.event.inputs.version }} )" >> $GITHUB_ENV | ||
- name: Publish Event | ||
uses: peter-evans/repository-dispatch@v3 | ||
with: | ||
token: ${{ steps.generate_token.outputs.token }} | ||
repository: ${{ github.repository_owner }}/ocm | ||
event-type: publish-ocm-cli | ||
client-payload: '{"version":"${{ env.RELEASE_VERSION }}","push-to-aur":${{ github.event.inputs.push-to-aur }},"push-to-chocolatey":${{ github.event.inputs.push-to-chocolatey }},"push-to-winget":${{ github.event.inputs.push-to-winget }}}' |
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 |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package ociutils | ||
|
||
import ( | ||
"strings" | ||
|
||
"github.com/mandelsoft/goutils/generics" | ||
"github.com/opencontainers/go-digest" | ||
) | ||
|
||
// ParseVersion parses the version part of an OCI reference consisting | ||
// of an optional tag and/or digest. | ||
func ParseVersion(vers string) (*ArtVersion, error) { | ||
if strings.HasPrefix(vers, "@") { | ||
dig, err := digest.Parse(vers[1:]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &ArtVersion{ | ||
Digest: &dig, | ||
}, nil | ||
} | ||
|
||
i := strings.Index(vers, "@") | ||
if i > 0 { | ||
dig, err := digest.Parse(vers[i+1:]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &ArtVersion{ | ||
Tag: generics.Pointer(vers[:i]), | ||
Digest: &dig, | ||
}, nil | ||
} | ||
return &ArtVersion{ | ||
Tag: &vers, | ||
}, nil | ||
} | ||
|
||
// ArtVersion is the version part of an OCI reference consisting of an | ||
// optional tag and/or digest. Both parts may be nil, if a reference | ||
// does not include a version part. | ||
// Such objects are sub objects of (oci.)ArtSpec, which has be moved | ||
// to separate package to avoid package cycles. The methods are | ||
// derived from ArtSpec. | ||
type ArtVersion struct { | ||
// +optional | ||
Tag *string `json:"tag,omitempty"` | ||
// +optional | ||
Digest *digest.Digest `json:"digest,omitempty"` | ||
} | ||
|
||
func (v *ArtVersion) VersionSpec() string { | ||
if v != nil { | ||
return "" | ||
} | ||
|
||
vers := "" | ||
if v.Tag != nil { | ||
vers = *v.Tag | ||
} | ||
|
||
if v.Digest != nil { | ||
vers += "@" + string(*v.Digest) | ||
} | ||
if vers == "" { | ||
return "latest" | ||
} | ||
return vers | ||
} | ||
|
||
// IsVersion returns true, if the object ref is given | ||
// and describes a dedicated version, either by tag or digest. | ||
// As part of the ArtSpec type in oci, it might describe | ||
// no version part. THis method indicates, whether a version part | ||
// is present. | ||
func (v *ArtVersion) IsVersion() bool { | ||
if v == nil { | ||
return false | ||
} | ||
return v.Tag != nil || v.Digest != nil | ||
} | ||
|
||
func (v *ArtVersion) IsTagged() bool { | ||
return v != nil && v.Tag != nil | ||
} | ||
|
||
func (v *ArtVersion) IsDigested() bool { | ||
return v != nil && v.Digest != nil | ||
} | ||
|
||
func (v *ArtVersion) GetTag() string { | ||
if v != nil && | ||
v.Tag != nil { | ||
return *v.Tag | ||
} | ||
return "" | ||
} |
Oops, something went wrong.