-
Notifications
You must be signed in to change notification settings - Fork 582
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
.github/workflows: add workflow to determine required version of go s…
…nap for testing
- Loading branch information
Showing
2 changed files
with
78 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
name: Determine Go snap versions | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
include-snapd-build-go-version: | ||
description: 'Flag instructing to lookup the version of Go snap used to build Snapd' | ||
required: false | ||
type: boolean | ||
include-latest-go-version: | ||
description: 'Flag instructing to lookup the latest version of Go snap' | ||
required: false | ||
type: boolean | ||
specific-go-versions: | ||
required: false | ||
type: string | ||
outputs: | ||
gochannels: | ||
description: 'JSON list of Go snap versions to use in gochannel matrix' | ||
|
||
jobs: | ||
determine: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
go-versions: ${{ steps.determine.outputs.go-versions }} | ||
steps: | ||
- name: Initialize Go versions list | ||
id: determine | ||
run: | | ||
# Initialize an empty list | ||
GO_VERSIONS=() | ||
# Optionally add specific versions | ||
if [ -n "${{ inputs.specific-go-versions }}" ]; then | ||
for VERSION in ${{ inputs.specific-go-versions }}; do | ||
GO_VERSIONS+=("$VERSION") | ||
done | ||
fi | ||
# Optionally add version that snapd is build with | ||
if [ "${{ inputs.include-snapd-build-go-version }}" = "true" ]; then | ||
# Simulate fetching the Snapd Go build version (replace with actual logic) | ||
BUILD_VERSION="1.18" | ||
GO_VERSIONS+=("$BUILD_VERSION") | ||
fi | ||
# Optionally add latest version | ||
if [ "${{ inputs.include-latest-go-version }}" = "true" ]; then | ||
# Simulate fetching the latest Go version (replace with actual logic) | ||
LATEST_VERSION="latest/stable" | ||
GO_VERSIONS+=("$LATEST_VERSION") | ||
fi | ||
# Remove duplicates and convert to JSON array | ||
UNIQUE_VERSIONS=$(printf '%s\n' "${GO_VERSIONS[@]}" | sort -u | jq -R . | jq -s .) | ||
# Output the list | ||
echo "::set-output name=go-versions::$UNIQUE_VERSIONS" |
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