Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
"git-lfs",
"gitlab-cli",
"go",
"gonovate",
"goreleaser",
"instant-client",
"jfrog-cli",
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Below is a list with included features, click on the link for more details.
| [git-lfs](./features/src/git-lfs/README.md) | Installs Git LFS. |
| [gitlab-cli](./features/src/gitlab-cli/README.md) | Installs the GitLab CLI. |
| [go](./features/src/go/README.md) | Installs Go. |
| [gonovate](./features/src/gonovate/README.md) | Installs Gonovate. |
| [goreleaser](./features/src/goreleaser/README.md) | Installs GoReleaser. |
| [instant-client](./features/src/instant-client/README.md) | Installs the Oracle Instant Client Basic package. |
| [jfrog-cli](./features/src/jfrog-cli/README.md) | Installs the JFrog CLI. |
Expand Down
11 changes: 11 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,17 @@ func init() {
return publishFeature("go")
})

////////// gonovate
gotaskr.Task("Feature:gonovate:Package", func() error {
return packageFeature("gonovate")
})
gotaskr.Task("Feature:gonovate:Test", func() error {
return testFeature("gonovate")
})
gotaskr.Task("Feature:gonovate:Publish", func() error {
return publishFeature("gonovate")
})

////////// goreleaser
gotaskr.Task("Feature:goreleaser:Package", func() error {
return packageFeature("goreleaser")
Expand Down
21 changes: 21 additions & 0 deletions features/src/gonovate/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Gonovate (gonovate)

Installs Gonovate.

## Example Usage

```json
"features": {
"ghcr.io/postfinance/devcontainer-features/gonovate:0.1.0": {
"version": "latest",
"downloadUrl": ""
}
}
```

## Options

| Option | Description | Type | Default Value | Proposals |
|-----|-----|-----|-----|-----|
| version | The version of Gonovate to install. | string | latest | latest, 0.6.6, 0.5 |
| downloadUrl | The download URL to use for Gonovate binaries. | string | <empty> | https://mycompany.com/artifactory/github-releases-remote |
26 changes: 26 additions & 0 deletions features/src/gonovate/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"id": "gonovate",
"version": "0.1.0",
"name": "Gonovate",
"description": "Installs Gonovate.",
"options": {
"version": {
"type": "string",
"proposals": [
"latest",
"0.6.6",
"0.5"
],
"default": "latest",
"description": "The version of Gonovate to install."
},
"downloadUrl": {
"type": "string",
"default": "",
"proposals": [
"https://mycompany.com/artifactory/github-releases-remote"
],
"description": "The download URL to use for Gonovate binaries."
}
}
}
5 changes: 5 additions & 0 deletions features/src/gonovate/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
. ./functions.sh

"./installer_$(detect_arch)" \
-version="${VERSION:-"latest"}" \
-downloadUrl="${DOWNLOADURL:-""}"
96 changes: 96 additions & 0 deletions features/src/gonovate/installer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
package main

import (
"builder/installer"
"flag"
"fmt"
"os"
"regexp"

"github.com/roemer/gover"
)

//////////
// Configuration
//////////

var versionRegex *regexp.Regexp = regexp.MustCompile(`(?m:)^v(?P<raw>(\d+).(\d+)\.(\d+))$`)

//////////
// Main
//////////

func main() {
if err := runMain(); err != nil {
fmt.Printf("Error: %v\n", err)
os.Exit(1)
}
}

func runMain() error {
// Handle the flags
version := flag.String("version", "latest", "")
downloadUrl := flag.String("downloadUrl", "", "")
flag.Parse()

// Load settings from an external file
if err := installer.LoadOverrides(); err != nil {
return err
}

// Apply override logic for URLs
installer.HandleGitHubOverride(downloadUrl, "roemer/gonovate", "gonovate-download-url")

// Create and process the feature
feature := installer.NewFeature("Gonovate", true,
&gonovateComponent{
ComponentBase: installer.NewComponentBase("Gonovate", *version),
DownloadUrl: *downloadUrl,
})
return feature.Process()
}

//////////
// Implementation
//////////

type gonovateComponent struct {
*installer.ComponentBase
DownloadUrl string
}

func (c *gonovateComponent) GetAllVersions() ([]*gover.Version, error) {
tags, err := installer.Tools.GitHub.GetTags("roemer", "gonovate")
if err != nil {
return nil, err
}
return installer.Tools.Versioning.ParseVersionsFromList(tags, versionRegex, true)
}

func (c *gonovateComponent) InstallVersion(version *gover.Version) error {
archPart, err := installer.Tools.System.MapArchitecture(map[string]string{
installer.AMD64: "amd64",
installer.ARM64: "arm64",
})
if err != nil {
return err
}
// Download the file
fileName := fmt.Sprintf("gonovate-linux-%s-%s.zip", version.Raw, archPart)
downloadUrl, err := installer.Tools.Http.BuildUrl(c.DownloadUrl, "v"+version.Raw, fileName)
if err != nil {
return err
}
if err := installer.Tools.Download.ToFile(downloadUrl, fileName, "gonovate"); err != nil {
return err
}
// Extract it
if err := installer.Tools.Compression.ExtractZip(fileName, "/usr/local/bin/", false); err != nil {
return err
}
// Cleanup
if err := os.Remove(fileName); err != nil {
return err
}
return nil
}
8 changes: 8 additions & 0 deletions features/test/gonovate/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash
set -e

[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh"
[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh"

check_file_exists "/usr/local/bin/gonovate"
check_version "$(gonovate 2>&1 | head -n 1)" "gonovate v0.10.5"
15 changes: 15 additions & 0 deletions features/test/gonovate/scenarios.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"install": {
"build": {
"dockerfile": "Dockerfile",
"options": [
"--add-host=host.docker.internal:host-gateway"
]
},
"features": {
"./gonovate": {
"version": "0.10.5"
}
}
}
}
6 changes: 6 additions & 0 deletions features/test/gonovate/test-images.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
"mcr.microsoft.com/devcontainers/base:debian-11",
"mcr.microsoft.com/devcontainers/base:debian-12",
"mcr.microsoft.com/devcontainers/base:alpine",
"mcr.microsoft.com/devcontainers/base:ubuntu-24.04"
]
3 changes: 3 additions & 0 deletions override-all.env
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ GO_DOWNLOAD_URL=""
GO_LATEST_URL=""
GO_VERSIONS_URL=""

# gonovate
GONOVATE_DOWNLOAD_URL=""

# goreleaser
GORELEASER_DOWNLOAD_URL=""

Expand Down