Skip to content

Commit

Permalink
Create dedicated Docker image for GH action
Browse files Browse the repository at this point in the history
  • Loading branch information
majori committed Nov 7, 2023
1 parent 3a379bd commit 2398727
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 30 deletions.
85 changes: 55 additions & 30 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,18 @@ builds:
goarch:
- amd64
- arm64
- id: github-action
dir: cmd/action
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64

kos:
- repository: ghcr.io/futurice/jalapeno
build: jalapeno
base_image: alpine
tags:
- latest
Expand All @@ -25,18 +34,34 @@ kos:
platforms:
- linux/amd64
- linux/arm64
labels:
labels: &labels
org.opencontainers.image.authors: "Jalapeno contributors <github.com/futurice/jalapeno>"
org.opencontainers.image.licenses: "Apache-2.0"
org.opencontainers.image.vendor: "Futurice"
org.opencontainers.image.title: "Jalapeno"
org.opencontainers.image.version: "v{{.Version}}"
org.opencontainers.image.description: "Jalapeno is a CLI for creating, managing and sharing spiced up project templates."
org.opencontainers.image.url: "https://github.com/futurice/jalapeno"
org.opencontainers.image.source: "https://github.com/futurice/jalapeno"
org.opencontainers.image.documentation: "https://futurice.github.io/jalapeno/"
- repository: ghcr.io/futurice/jalapeno
build: github-action
base_image: alpine
tags:
- "latest-githubaction"
- "v{{.Version}}-githubaction"
- "v{{.Major}}-githubaction"
- "v{{.Major}}.{{.Minor}}-githubaction"
sbom: none
bare: true
preserve_import_paths: false
platforms:
- linux/amd64
labels: *labels

archives:
- id: jalapeno
builds: [jalapeno]
name_template: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}"
format_overrides:
- goos: windows
Expand Down Expand Up @@ -77,32 +102,32 @@ brews:
system "#{bin}/jalapeno --version"
winget:
- name: jalapeno
publisher: Futurice
publisher_url: https://www.futurice.com
publisher_support_url: https://github.com/futurice/jalapeno/issues/new
short_description: Jalapeno is a CLI for creating, managing and sharing spiced up project templates
license: "Apache-2.0"
homepage: https://futurice.github.io/jalapeno/
license_url: https://github.com/futurice/jalapeno/blob/main/LICENCE
release_notes: '{{ .Changelog }}'
release_notes_url: 'https://github.com/futurice/jalapeno/releases/tag/{{ .Tag }}'
tags:
- cli
- configuration
- project
- bootstrap
- templates
repository:
owner: futurice
name: winget-pkgs
branch: "{{.ProjectName}}-{{.Version}}"
git:
url: "[email protected]:futurice/winget-pkgs.git"
private_key: "{{ .Env.WINGET_PKGS_PRIVATE_KEY }}"
pull_request:
enabled: true
base:
owner: microsoft
name: winget-pkgs
branch: master
- name: jalapeno
publisher: Futurice
publisher_url: https://www.futurice.com
publisher_support_url: https://github.com/futurice/jalapeno/issues/new
short_description: Jalapeno is a CLI for creating, managing and sharing spiced up project templates
license: "Apache-2.0"
homepage: https://futurice.github.io/jalapeno/
license_url: https://github.com/futurice/jalapeno/blob/main/LICENCE
release_notes: "{{ .Changelog }}"
release_notes_url: "https://github.com/futurice/jalapeno/releases/tag/{{ .Tag }}"
tags:
- cli
- configuration
- project
- bootstrap
- templates
repository:
owner: futurice
name: winget-pkgs
branch: "{{.ProjectName}}-{{.Version}}"
git:
url: "[email protected]:futurice/winget-pkgs.git"
private_key: "{{ .Env.WINGET_PKGS_PRIVATE_KEY }}"
pull_request:
enabled: true
base:
owner: microsoft
name: winget-pkgs
branch: master
7 changes: 7 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: "Jalapeno"
description: "Run Jalapeno check-updates on a project"
runs:
using: "docker"
image: "docker://ghcr.io/futurice/jalapeno:v0-githubaction"
args:
- check
43 changes: 43 additions & 0 deletions cmd/action/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package main

import (
"errors"
"fmt"
"os"

"github.com/futurice/jalapeno/internal/cli"
"github.com/gofrs/uuid"
)

var (
// https://goreleaser.com/cookbooks/using-main.version/
version string
)

func main() {
filename := os.Getenv("GITHUB_OUTPUT")
if filename == "" {
checkErr(errors.New("GITHUB_OUTPUT environment variable not set"))
}

output, err := os.OpenFile(filename, os.O_APPEND, 0644)
checkErr(err)

cmd := cli.NewRootCmd(version)
delimiter := uuid.Must(uuid.NewV4()).String()
fmt.Fprintf(output, "result<<%s\n", delimiter)

// TODO: Add result

fmt.Fprintf(output, "%s\n", delimiter)

err = cmd.Execute()
checkErr(err)
}

func checkErr(err error) {
if err != nil {
fmt.Printf("%+v\n", err)
os.Exit(1)
}
}

0 comments on commit 2398727

Please sign in to comment.