Skip to content

Commit

Permalink
Merge pull request #5 from amp-buildpacks/feat/starkli
Browse files Browse the repository at this point in the history
Finish v0.1.0
  • Loading branch information
wangeguo authored Jun 9, 2024
2 parents 876664a + b3a9a55 commit e6b7bc2
Show file tree
Hide file tree
Showing 13 changed files with 804 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .github/pipeline-descriptor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
github:
username: ${{ github.actor }}
token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}

package:
repositories: ["ghcr.io/amp-buildpacks/starknet"]
register: false
registry_token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}

docker_credentials:
- registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}
93 changes: 93 additions & 0 deletions .github/workflows/pb-update-pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: Update Pipeline
"on":
push:
branches:
- main
paths:
- .github/pipeline-descriptor.yml
schedule:
- cron: 0 5 * * 1-5
workflow_dispatch: {}
jobs:
update:
name: Update Pipeline
runs-on:
- ubuntu-latest
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
- name: Install octo
run: |
#!/usr/bin/env bash
set -euo pipefail
go install -ldflags="-s -w" github.com/paketo-buildpacks/pipeline-builder/cmd/octo@latest
- uses: actions/checkout@v4
- name: Update Pipeline
id: pipeline
run: |
#!/usr/bin/env bash
set -euo pipefail
if [[ -f .github/pipeline-version ]]; then
OLD_VERSION=$(cat .github/pipeline-version)
else
OLD_VERSION="0.0.0"
fi
rm .github/workflows/pb-*.yml || true
octo --descriptor "${DESCRIPTOR}"
PAYLOAD=$(gh api /repos/paketo-buildpacks/pipeline-builder/releases/latest)
NEW_VERSION=$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.name')
echo "${NEW_VERSION}" > .github/pipeline-version
RELEASE_NOTES=$(
gh api \
-F text="$(jq -n -r --argjson PAYLOAD "${PAYLOAD}" '$PAYLOAD.body')" \
-F mode="gfm" \
-F context="paketo-buildpacks/pipeline-builder" \
-X POST /markdown
)
git add .github/
git add .gitignore
if [ -f scripts/build.sh ]; then
git add scripts/build.sh
fi
git checkout -- .
echo "old-version=${OLD_VERSION}" >> "$GITHUB_OUTPUT"
echo "new-version=${NEW_VERSION}" >> "$GITHUB_OUTPUT"
DELIMITER=$(openssl rand -hex 16) # roughly the same entropy as uuid v4 used in https://github.com/actions/toolkit/blob/b36e70495fbee083eb20f600eafa9091d832577d/packages/core/src/file-command.ts#L28
printf "release-notes<<%s\n%s\n%s\n" "${DELIMITER}" "${RELEASE_NOTES}" "${DELIMITER}" >> "${GITHUB_OUTPUT}" # see https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#multiline-strings
env:
DESCRIPTOR: .github/pipeline-descriptor.yml
GITHUB_TOKEN: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}
- uses: peter-evans/create-pull-request@v6
with:
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
body: |-
Bumps pipeline from `${{ steps.pipeline.outputs.old-version }}` to `${{ steps.pipeline.outputs.new-version }}`.
<details>
<summary>Release Notes</summary>
${{ steps.pipeline.outputs.release-notes }}
</details>
branch: update/pipeline
commit-message: |-
Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}
Bumps pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}.
delete-branch: true
labels: semver:patch, type:task
signoff: true
title: Bump pipeline from ${{ steps.pipeline.outputs.old-version }} to ${{ steps.pipeline.outputs.new-version }}
token: ${{ secrets.AMP_BUILDPACKS_BOT_GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) The Amphitheatre Authors. All rights reserved.
#
# 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.

bin/
dependencies/
package/
scratch/
70 changes: 69 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,70 @@
# starknet
# `ghcr.io/amp-buildpacks/starknet`

A Cloud Native Buildpack that provides the Starknet Tool Suite

## Configuration

| Environment Variable | Description |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `$BP_STARKNET_VERSION` | Configure the version of Starknet to install. It defaults to the latest `0.3.0` version. |


## Usage

### 1. To use this buildpack, simply run:

```shell
pack build <image-name> \
--path <starknet-samples-path> \
--buildpack ghcr.io/amp-buildpacks/starknet \
--builder paketobuildpacks/builder-jammy-base
```

For example:

```shell
pack build starknet-sample \
--path ./samples/cairo/starknet \
--buildpack ghcr.io/amp-buildpacks/starknet \
--builder paketobuildpacks/builder-jammy-base
```

### 2. To run the image, simply run:

```shell
docker run -u <uid>:<gid> -it <image-name>
```

For example:

```shell
docker run -u 1001:cnb -it starknet-sample
```

## Contributing

If anything feels off, or if you feel that some functionality is missing, please
check out the [contributing
page](https://docs.amphitheatre.app/contributing/). There you will find
instructions for sharing your feedback, building the tool locally, and
submitting pull requests to the project.

## License

Copyright (c) The Amphitheatre Authors. All rights reserved.

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.

## Credits

Heavily inspired by https://buildpacks.io/docs/buildpack-author-guide/create-buildpack/
104 changes: 104 additions & 0 deletions buildpack.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# Copyright (c) The Amphitheatre Authors. All rights reserved.
#
# 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.

api = "0.8"

[buildpack]
description = "A Cloud Native Buildpack that provides the Starknet Tool Suite"
homepage = "https://github.com/amp-buildpacks/starknet"
id = "amp-buildpacks/starknet"
keywords = ["Starknet"]
sbom-formats = ["application/vnd.cyclonedx+json", "application/vnd.syft+json"]
name = "AMP Buildpack for Starknet"
version = "{{ .version }}"

[[buildpack.licenses]]
type = "Apache-2.0"
uri = "https://github.com/amp-buildpacks/starknet/blob/main/LICENSE"

[metadata]
include-files = ["LICENSE", "README.md", "linux/amd64/bin/build", "linux/amd64/bin/detect", "linux/amd64/bin/main", "linux/arm64/bin/build", "linux/arm64/bin/detect", "linux/arm64/bin/main", "buildpack.toml"]
pre-package = "scripts/build.sh"

[[metadata.configurations]]
build = true
default = "0.3.0"
description = "The Starknet version"
name = "BP_STARKNET_VERSION"

[[metadata.configurations]]
build = true
default = "gnu"
description = "libc implementation: gnu or musl"
name = "BP_STARKNET_LIBC"

[[metadata.configurations]]
build = true
default = "true"
description = "Enable the Starknet deploy tool"
name = "BP_ENABLE_STARKNET_DEPLOY"

[[metadata.configurations]]
build = true
description = "Configure the wallet private key for Starknet deploy"
name = "BP_STARKNET_DEPLOY_PRIVATE_KEY"

[[metadata.configurations]]
build = true
description = "Configure the wallet address for Starknet deploy"
name = "BP_STARKNET_DEPLOY_WALLET_ADDRESS"

[[metadata.configurations]]
build = true
default = "/workspace/starkli-wallets/deployer_account.json"
description = "Configure the wallet account for Starknet deploy"
name = "BP_STARKNET_DEPLOY_ACCOUNT"

[[metadata.configurations]]
build = true
default = "https://starknet-sepolia.public.blastapi.io/rpc/v0_7"
description = "Configure the rpc for Starknet deploy"
name = "BP_STARKNET_DEPLOY_RPC"

[[metadata.dependencies]]
id = "starkli-gnu"
name = "Starkli (GNU libc)"
purl = "pkg:generic/[email protected]"
sha256 = "fab1ff015a018722b4dad51d1ebbd1b682a74425d83d433ec96d87abb9317c59"
uri = "https://github.com/xJonathanLEI/starkli/releases/download/v0.3.0/starkli-x86_64-unknown-linux-gnu.tar.gz"
stacks = ["*"]
version = "0.3.0"
licenses = [ "GNU" ]

[[metadata.dependencies]]
id = "starkli-musl"
name = "Starkli (musl libc)"
purl = "pkg:generic/[email protected]"
sha256 = "a6523c2b036af9bb715f7a658849398368113d4df56a9e99ceb681a9aa9e54c7"
uri = "https://github.com/xJonathanLEI/starkli/releases/download/v0.3.0/starkli-x86_64-unknown-linux-musl.tar.gz"
stacks = ["*"]
version = "0.3.0"
licenses = [ "GNU" ]


[[stacks]]
id = "*"

[[targets]]
arch = "amd64"
os = "linux"

[[targets]]
arch = "arm64"
os = "linux"
30 changes: 30 additions & 0 deletions cmd/main/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) The Amphitheatre Authors. All rights reserved.
//
// 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 (
"os"

starknet "github.com/amp-buildpacks/starknet/starknet"
"github.com/buildpacks/libcnb"
"github.com/paketo-buildpacks/libpak/bard"
)

func main() {
libcnb.Main(
starknet.Detect{},
starknet.Build{Logger: bard.NewLogger(os.Stdout)},
)
}
17 changes: 17 additions & 0 deletions config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[[dependencies]]
id = "starkli-gnu"
name = "Starkli (GNU libc)"
pkg_name = "starkli"
sha256 = "fab1ff015a018722b4dad51d1ebbd1b682a74425d83d433ec96d87abb9317c59"
uri = "https://github.com/xJonathanLEI/starkli/releases/download/v0.3.0/starkli-x86_64-unknown-linux-gnu.tar.gz"
version = "0.3.0"
license = "GNU"

[[dependencies]]
id = "starkli-musl"
name = "Starkli (musl libc)"
pkg_name = "starkli"
sha256 = "a6523c2b036af9bb715f7a658849398368113d4df56a9e99ceb681a9aa9e54c7"
uri = "https://github.com/xJonathanLEI/starkli/releases/download/v0.3.0/starkli-x86_64-unknown-linux-musl.tar.gz"
version = "0.3.0"
license = "GNU"
23 changes: 23 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module github.com/amp-buildpacks/starknet

go 1.21

require (
github.com/buildpacks/libcnb v1.30.1
github.com/paketo-buildpacks/libpak v1.68.1
)

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/h2non/filetype v1.1.3 // indirect
github.com/heroku/color v0.0.6 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect
github.com/onsi/gomega v1.31.1 // indirect
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
golang.org/x/sys v0.16.0 // indirect
)
Loading

0 comments on commit e6b7bc2

Please sign in to comment.