Skip to content

Commit

Permalink
Adds clojure-tools action
Browse files Browse the repository at this point in the history
- Adds an action for checking for updates to clojure-tools
- Updates the pipeline-descriptor to add a job to publish the action
- Documents the action
- Documents other actions that were missing documentation

Signed-off-by: Daniel Mikusa <dmikusa@vmware.com>
  • Loading branch information
Daniel Mikusa committed Oct 8, 2021
1 parent 84b5ba6 commit ac377f5
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ actions:
target: ghcr.io/paketo-buildpacks/actions/ca-apm-dependency
- source: cf-java-index-dependency
target: ghcr.io/paketo-buildpacks/actions/cf-java-index-dependency
- source: clojure-tools-dependency
target: ghcr.io/paketo-buildpacks/actions/clojure-tools-dependency
- source: foojay-dependency
target: ghcr.io/paketo-buildpacks/actions/foojay-dependency
- source: gcs-dependency
Expand Down
79 changes: 79 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,32 @@ The Pipeline Builder is a collection of tools related to GitHub Actions and othe
- [`actions`](#actions)
- [Actions](#actions-1)
- [Adoptium Dependency](#adoptium-dependency)
- [Alibaba Dragonwell Dependency](#alibaba-dragonwell-dependency)
- [Amazon Corretto Dependency](#amazon-corretto-dependency)
- [AppDynamics Dependency](#appdynamics-dependency)
- [Aqua Security Dependency](#aqua-security-dependency)
- [Azul Zulu Dependency](#azul-zulu-dependency)
- [Bellsoft Liberica Dependency](#bellsoft-liberica-dependency)
- [CA APM Dependency](#ca-apm-dependency)
- [CF Java Index Dependency](#cf-java-index-dependency)
- [Clojure Tools Dependency](#clojure-tools-dependency)
- [Foojay Dependency](#foojay-dependency)
- [GCS Dependency](#gcs-dependency)
- [GitHub Release Dependency](#github-release-dependency)
- [Google Stackdriver Profiler Dependency](#google-stackdriver-profiler-dependency)
- [GraalVM Dependency](#graalvm-dependency)
- [Gradle Dependency](#gradle-dependency)
- [IBM Semeru Dependency](#ibm-semeru-dependency)
- [JProfiler Dependency](#jprofiler-dependency)
- [JRebel Dependency](#jrebel-dependency)
- [Leiningen Dependency](#leiningen-dependency)
- [Maven Dependency](#maven-dependency)
- [New Relic Dependency](#new-relic-dependency)
- [NPM Dependency](#npm-dependency)
- [OverOps Dependency](#overops-dependency)
- [Paketo Deps Dependency](#paketo-deps-dependency)
- [Riverbed Dependency](#riverbed-dependency)
- [Rustup Init Dependency](#rustup-init-dependency)
- [Skywalking Dependency](#skywalking-dependency)
- [Spring Generations](#spring-generations)
- [Tomcat Dependency](#tomcat-dependency)
Expand Down Expand Up @@ -251,6 +258,17 @@ with:
version: "[11,12)"
```

### Alibaba Dragonwell Dependency
The Alibaba Dependency watches [Alibaba repositories](https://github.com/alibaba/) for new versions.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/alibaba-dragonwell-dependency:main
with:
glob: Alibaba_Dragonwell_[\d\.]+_x64_linux.tar.gz$
repository: dragonwell<jdk-version>
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
```

### Amazon Corretto Dependency
The Amazon Corretto Dependency watches [Amazon Corretto repositories](https://github.com/corretto/) for new versions.

Expand Down Expand Up @@ -309,6 +327,35 @@ with:
type: java
```

### CF Java Index Dependency
The CF Java Index Dependency querys a CloudFoundry Java buildpack v2 `index.yml` file for new versions.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/cf-java-index-dependency:main
with:
repository_root: <repo-root>
```

### Clojure Tools Dependency
The Clojure Tools Dependency watches [Clojure Tools repositories](https://github.com/clojure/clojure-tools) for new versions. It then filters based on the [stable.properties](https://raw.githubusercontent.com/clojure/brew-install/%s/stable.properties) file in their brew tap repo, allowing it to pick the most recent stable version.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/alibaba-dragonwell-dependency:main
with:
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
```

### Foojay Dependency
The Foojay Dependency queries the [Foojay API](https://api.foojay.io/swagger-ui#/) for new versions.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/foojay-dependency:main
with:
distro: microsoft
type: jdk
version: "11"
```

### GCS Dependency
The GCS Dependency watches [GCS Buckets](https://cloud.google.com/storage) for new versions. The first capture in `glob` is used as the version.

Expand Down Expand Up @@ -357,6 +404,19 @@ The Gradle Dependency queries the [Gradle API](https://raw.githubusercontent.com
uses: docker://ghcr.io/paketo-buildpacks/actions/gradle-dependency:main
```

### IBM Semeru Dependency
The IBM Semeru Dependency queries the [Gradle API](https://raw.githubusercontent.com/gradle/gradle/master/released-versions.json) for new versions.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/ibm-semeru-dependency:main
with:
glob: ibm-semeru-open-jdk_x64_linux_.+_openj9-.+.tar.gz
owner: ibmruntimes
repository: semeru8-binaries
tag_filter: jdk(.*8.*)
token: ${{ secrets.JAVA_GITHUB_TOKEN }}
```

### JProfiler Dependency
The JProfiler Dependency watches the [JProfiler Changelog](https://www.ej-technologies.com/download/jprofiler/changelog.html) for new versions.

Expand Down Expand Up @@ -418,13 +478,32 @@ The OverOps Dependency watches the [OverOps Download Page](https://app.overops.c
uses: docker://ghcr.io/paketo-buildpacks/actions/overops-dependency:main
```

### Paketo Deps Dependency
The Paketo Deps Dependency queries the [Paketo Deps Server](https://api.deps.paketo.io/v1/dependency?name) for new versions.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/paketo-deps-dependency:main
with:
name: rust
```

### Riverbed Dependency
The Riverbed Dependency watches the [Riverbed Bucket](http://s3.amazonaws.com/appint-pcf-instrumentation-rpm-master) for new versions.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/riverbed-dependency:main
```

### Rustup Init Dependency
The Rustup Init Dependency queries the [Rustup Github Project](https://github.com/rust-lang/rustup) for new versions. The `target` specifies the target triple to download.

```yaml
uses: docker://ghcr.io/paketo-buildpacks/actions/rustup-init-dependency:main
with:
target: x86_64-unknown-linux-musl
token: ${{ secrets.PAKETO_BOT_GITHUB_TOKEN }}
```

### Skywalking Dependency
The Skywalking Dependency watches the [Apache Skywalking Download Page](https://archive.apache.org/dist/skywalking) for new versions.

Expand Down
111 changes: 111 additions & 0 deletions actions/clojure-tools-dependency/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*
* Copyright 2018-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package main

import (
"context"
"fmt"
"io"
"log"
"net/http"
"os"
"strings"

"github.com/google/go-github/v32/github"
"github.com/paketo-buildpacks/pipeline-builder/actions"
"golang.org/x/oauth2"
)

const (
ORG = "clojure"
REPO = "brew-install"
)

func main() {
inputs := actions.NewInputs()

var c *http.Client
if s, ok := inputs["token"]; ok {
c = oauth2.NewClient(context.Background(), oauth2.StaticTokenSource(&oauth2.Token{AccessToken: s}))
}
gh := github.NewClient(c)

versions := make(actions.Versions)

// fetch all the versions from tags
opt := &github.ListOptions{PerPage: 100}
for {
tags, rsp, err := gh.Repositories.ListTags(context.Background(), ORG, REPO, opt)
if err != nil {
panic(fmt.Errorf("unable to list existing tags for %s/%s\n%w", ORG, REPO, err))
}

for _, t := range tags {
normalVersion, err := actions.NormalizeVersion(*t.Name)
if err != nil {
panic(err)
}

versions[normalVersion] = fmt.Sprintf("https://download.clojure.org/install/linux-install-%s.sh", *t.Name)
}

if rsp.NextPage == 0 {
break
}
opt.Page = rsp.NextPage
}

// pick the most recent, this gives us the most recent major.minor.patch
if o, err := versions.GetLatest(inputs); err != nil {
panic(err)
} else {
version := o["version"]

uri := fmt.Sprintf("https://raw.githubusercontent.com/clojure/brew-install/%s/stable.properties",
version)

resp, err := http.Get(uri)
if err != nil {
panic(fmt.Errorf("unable to get %s\n%w", uri, err))
}
defer resp.Body.Close()

if resp.StatusCode != 200 {
panic(fmt.Errorf("unable to download %s: %d", uri, resp.StatusCode))
}

b, err := io.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}

origVersion := strings.Split(string(b), " ")[0]
normalVersion, err := actions.NormalizeVersion(origVersion)
if err != nil {
panic(err)
}

versions := make(actions.Versions)
versions[normalVersion] = fmt.Sprintf("https://download.clojure.org/install/linux-install-%s.sh", origVersion)
}

if o, err := versions.GetLatest(inputs); err != nil {
panic(err)
} else {
o.Write(os.Stdout)
}
}

0 comments on commit ac377f5

Please sign in to comment.