Skip to content

Commit

Permalink
feat: support pinning versions with new auto-upgrade functionality (#112
Browse files Browse the repository at this point in the history
)

* feat: support pinning versions with new auto-upgrade functionality

* chore: pin to php82

* fix: ln php82 => php

* chore: remove comment

* chore: use version pinning flag

* chore: use v15-test

* chore: remove -test flag

* chore: remove version pinnning feature flag
  • Loading branch information
chase-crumbaugh authored Apr 17, 2024
1 parent 0db9095 commit 34fba85
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,14 @@ RUN dotnet --list-sdks
RUN apk --update --no-cache add wget \
curl \
git \
php \
php82 \
php-ctype php-dom php-json php-mbstring php-phar php-tokenizer php-xml php-xmlwriter \
php-curl \
php-openssl \
php-iconv \
--repository http://nl.alpinelinux.org/alpine/edge/testing/

RUN ln -s /usr/bin/php82 /usr/bin/php
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
RUN mkdir -p /var/www
WORKDIR /var/www
Expand Down
15 changes: 9 additions & 6 deletions internal/actions/runWorkflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ package actions

import (
"fmt"

"github.com/hashicorp/go-version"
"github.com/speakeasy-api/sdk-generation-action/internal/configuration"
"github.com/speakeasy-api/sdk-generation-action/internal/git"
"github.com/speakeasy-api/sdk-generation-action/internal/run"
Expand All @@ -20,14 +18,19 @@ func RunWorkflow() error {
return err
}

resolvedVersion, err := cli.Download(environment.GetPinnedSpeakeasyVersion(), g)
// The top-level CLI can always use latest. The CLI itself manages pinned versions.
resolvedVersion, err := cli.Download("latest", g)
if err != nil {
return err
}

minimumVersionForRun := version.Must(version.NewVersion("1.161.0"))
if !cli.IsAtLeastVersion(minimumVersionForRun) {
return fmt.Errorf("action requires at least version %s of the speakeasy CLI", minimumVersionForRun)
pinnedVersion := cli.GetVersion(environment.GetPinnedSpeakeasyVersion())
if pinnedVersion != "latest" {
resolvedVersion = pinnedVersion
// This environment variable is read by the CLI to determine which version should be used to execute `run`
if err := environment.SetCLIVersionToUse(pinnedVersion); err != nil {
return fmt.Errorf("failed to set pinned speakeasy version: %w", err)
}
}

mode := environment.GetMode()
Expand Down
4 changes: 4 additions & 0 deletions internal/environment/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,3 +218,7 @@ func GetWorkspace() string {
func ShouldOutputTests() bool {
return os.Getenv("INPUT_OUTPUT_TESTS") == "true"
}

func SetCLIVersionToUse(version string) error {
return os.Setenv("PINNED_VERSION", version)
}

0 comments on commit 34fba85

Please sign in to comment.