diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..d8494ce --- /dev/null +++ b/.dockerignore @@ -0,0 +1,3 @@ +Dockerfile +README.md +.github/ diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..4fcaebb --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,15 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates + +version: 2 +updates: + - package-ecosystem: "docker" + directory: "/" + schedule: + interval: "weekly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "weekly" diff --git a/.github/workflows/ci-docker.yml b/.github/workflows/ci-docker.yml new file mode 100644 index 0000000..66a243e --- /dev/null +++ b/.github/workflows/ci-docker.yml @@ -0,0 +1,85 @@ +name: Docker CI + +on: + pull_request: + branches: ['main'] + paths: ['Dockerfile','.github/workflows/ci-docker.yml'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: blinklabs/cardano-cli + +jobs: + build-amd64: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: qemu + uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v3 + - uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-buildx- + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + latest=false + suffix=-amd64 + - name: build + uses: docker/build-push-action@v5 + with: + context: . + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # TEMP fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + + build-arm64: + runs-on: ["self-hosted", "ARM64"] + steps: + - uses: actions/checkout@v4 + - name: qemu + uses: docker/setup-qemu-action@v2 + - uses: docker/setup-buildx-action@v3 + - uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-buildx- + - id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + flavor: | + latest=false + suffix=-arm64v8 + - name: build + uses: docker/build-push-action@v5 + with: + context: . + push: false + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # TEMP fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache diff --git a/.github/workflows/conventional-commits.yml b/.github/workflows/conventional-commits.yml new file mode 100644 index 0000000..6502a2e --- /dev/null +++ b/.github/workflows/conventional-commits.yml @@ -0,0 +1,16 @@ +# The below is pulled from upstream and slightly modified +# https://github.com/webiny/action-conventional-commits/blob/master/README.md#usage + +name: Conventional Commits + +on: + pull_request: + +jobs: + build: + name: Conventional Commits + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - uses: webiny/action-conventional-commits@v1.0.3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..15983f6 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,311 @@ +name: publish + +on: + push: + branches: ['main'] + tags: ['v*.*.*'] + +concurrency: ${{ github.ref }} + +env: + DOCKER_IMAGE_NAME: blinklabs/cardano-cli + GHCR_IMAGE_NAME: ghcr.io/blinklabs-io/cardano-cli + +jobs: + + build-amd64: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: blinklabs + password: ${{ secrets.DOCKER_PASSWORD }} # uses token + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-buildx- + - id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.DOCKER_IMAGE_NAME }} + ${{ env.GHCR_IMAGE_NAME }} + flavor: | + latest=false + suffix=-amd64 + tags: | + # Only version, no revision + type=match,pattern=v(.*)-(.*),group=1 + # branch + type=ref,event=branch + # semver + type=semver,pattern={{version}} + - name: push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # TEMP fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + # TEMP fix + # Something strange is happening with the manifests when we push which + # breaks the downstream multi-arch-manifest, so pull and push to work + # around this by resubmitting manifests + - name: pull-and-push + run: | + for t in `echo '${{ steps.meta.outputs.tags }}'`; do + docker pull $t && docker push $t + done + + build-arm64: + runs-on: ["self-hosted", "ARM64"] + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: blinklabs + password: ${{ secrets.DOCKER_PASSWORD }} # uses token + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/cache@v3 + with: + path: /tmp/.buildx-cache + key: ${{ runner.os }}-${{ runner.arch }}-buildx-${{ github.sha }} + restore-keys: | + ${{ runner.os }}-${{ runner.arch }}-buildx- + - id: meta + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.DOCKER_IMAGE_NAME }} + ${{ env.GHCR_IMAGE_NAME }} + flavor: | + latest=false + suffix=-arm64v8 + tags: | + # Only version, no revision + type=match,pattern=v(.*)-(.*),group=1 + # branch + type=ref,event=branch + # semver + type=semver,pattern={{version}} + - name: push + uses: docker/build-push-action@v5 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=local,src=/tmp/.buildx-cache + cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max + # TEMP fix + # https://github.com/docker/build-push-action/issues/252 + # https://github.com/moby/buildkit/issues/1896 + - name: cache + run: | + rm -rf /tmp/.buildx-cache + mv /tmp/.buildx-cache-new /tmp/.buildx-cache + # TEMP fix + # Something strange is happening with the manifests when we push which + # breaks the downstream multi-arch-manifest, so pull and push to work + # around this by resubmitting manifests + - name: pull-and-push + run: | + for t in `echo '${{ steps.meta.outputs.tags }}'`; do + docker pull $t && docker push $t + done + + multi-arch-manifest: + runs-on: ubuntu-latest + needs: [build-amd64, build-arm64] + permissions: + contents: read + packages: write + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-buildx-action@v3 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: blinklabs + password: ${{ secrets.DOCKER_PASSWORD }} # uses token + - name: Login to GHCR + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - id: meta-dockerhub + name: Metadata - Docker Hub + uses: docker/metadata-action@v5 + with: + images: ${{ env.DOCKER_IMAGE_NAME }} + flavor: | + latest=false + tags: | + # Only version, no revision + type=match,pattern=v(.*)-(.*),group=1 + # branch + type=ref,event=branch + # semver + type=semver,pattern={{version}} + - id: meta-dockerhub-tag + name: Metadata - Docker Hub (Tags) + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.DOCKER_IMAGE_NAME }} + flavor: | + latest=false + tags: | + # Only version, no revision + type=match,pattern=v(.*)-(.*),group=1 + - id: meta-ghcr + name: Metadata - GHCR + uses: docker/metadata-action@v5 + with: + images: ${{ env.GHCR_IMAGE_NAME }} + flavor: | + latest=false + tags: | + # Only version, no revision + type=match,pattern=v(.*)-(.*),group=1 + # branch + type=ref,event=branch + # semver + type=semver,pattern={{version}} + - id: meta-ghcr-tag + name: Metadata - GHCR (Tags) + uses: docker/metadata-action@v5 + with: + images: | + ${{ env.GHCR_IMAGE_NAME }} + flavor: | + latest=false + tags: | + # Only version, no revision + type=match,pattern=v(.*)-(.*),group=1 + + # First, create manifests and push to GHCR + + # Manifest for either branch or semver + - name: manifest-ghcr + run: | + for t in `echo '${{ steps.meta-ghcr.outputs.tags }}'`; do + docker manifest create ${t} --amend ${t}-amd64 --amend ${t}-arm64v8 + done + # Optional manifest for tag versions (includes revisions) + - name: manifest-ghcr-tags + run: | + for t in `echo '${{ steps.meta-ghcr-tag.outputs.tags }}'`; do + docker manifest create ${t} --amend ${t}-amd64 --amend ${t}-arm64v8 + docker manifest create ${{ env.GHCR_IMAGE_NAME }}:latest --amend ${t}-amd64 --amend ${t}-arm64v8 + done + if: startsWith(github.ref, 'refs/tags/') + # Push various manifests + - name: push-ghcr + run: | + for t in `echo '${{ steps.meta-ghcr.outputs.tags }}'`; do + docker manifest push ${t} + done + - name: push-ghcr-tags + run: | + docker manifest push ${{ env.GHCR_IMAGE_NAME }}:latest + for t in `echo '${{ steps.meta-ghcr-tag.outputs.tags }}'`; do + docker manifest push ${t} + done + if: startsWith(github.ref, 'refs/tags/') + + # Now, create manifests for Docker Hub + + - name: manifest-dockerhub + run: | + for t in `echo '${{ steps.meta-dockerhub.outputs.tags }}'`; do + docker manifest create ${t} --amend ${t}-amd64 --amend ${t}-arm64v8 + done + - name: manifest-dockerhub-tags + run: | + for t in `echo '${{ steps.meta-dockerhub-tag.outputs.tags }}'`; do + docker manifest create ${t} --amend ${t}-amd64 --amend ${t}-arm64v8 + docker manifest create ${{ env.DOCKER_IMAGE_NAME }}:latest --amend ${t}-amd64 --amend ${t}-arm64v8 + done + if: startsWith(github.ref, 'refs/tags/') + - name: push-dockerhub + run: | + for t in `echo '${{ steps.meta-dockerhub.outputs.tags }}'`; do + docker manifest push ${t} + done + - name: push-dockerhub-tags + run: | + docker manifest push ${{ env.DOCKER_IMAGE_NAME }}:latest + for t in `echo '${{ steps.meta-dockerhub-tag.outputs.tags }}'`; do + docker manifest push ${t} + done + if: startsWith(github.ref, 'refs/tags/') + + # Update Docker Hub from README + + - name: Docker Hub Description + uses: peter-evans/dockerhub-description@v3 + with: + username: blinklabs + password: ${{ secrets.DOCKER_PASSWORD }} + repository: ${{ env.DOCKER_IMAGE_NAME }} + readme-filepath: ./README.md + short-description: "Cardano CLI built from source on Debian" + + github-release: + runs-on: ubuntu-latest + needs: [multi-arch-manifest] + steps: + - run: "echo \"RELEASE_TAG=${GITHUB_REF#refs/tags/}\" >> $GITHUB_ENV" + - uses: actions/github-script@v5 + if: startsWith(github.ref, 'refs/tags/') + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.repos.createRelease({ + draft: false, + generate_release_notes: true, + name: process.env.RELEASE_TAG, + owner: context.repo.owner, + prerelease: false, + repo: context.repo.repo, + tag_name: process.env.RELEASE_TAG, + }); + } catch (error) { + core.setFailed(error.message); + } diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000..1eea048 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,3 @@ +# Blink Labs +# +* @agaffney @verbotenj @wolf31o2 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..639c0e8 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,80 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. + +## Our Standards + +Examples of behavior that contributes to a positive environment for our community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, without their explicit permission +* Contacting individual members, contributors, or leaders privately, outside designated community mechanisms, without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Enforcement Responsibilities + +Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. + +## Scope + +This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at abuse@blinklabs.io. All complaints will be reviewed and investigated promptly and fairly. + +All community leaders are obligated to respect the privacy and security of the reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of actions. + +**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the community. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, available at . + +Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). + +[homepage]: https://www.contributor-covenant.org + +For answers to common questions about this code of conduct, see the FAQ at . Translations are available at . diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..64a0661 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +FROM ghcr.io/blinklabs-io/haskell:9.6.3-3.10.2.0-1 AS cardano-cli-build +# Install cardano-cli +ARG CLI_VERSION=8.17.0.0 +ENV CLI_VERSION=${CLI_VERSION} +RUN echo "Building tags/${CLI_VERSION}..." \ + && echo tags/cardano-cli-${CLI_VERSION} > /CARDANO_BRANCH \ + && git clone https://github.com/input-output-hk/cardano-cli.git \ + && cd cardano-cli \ + && git fetch --all --recurse-submodules --tags \ + && git tag \ + && git checkout tags/cardano-cli-${CLI_VERSION} \ + && echo "with-compiler: ghc-${GHC_VERSION}" >> cabal.project.local \ + && echo "tests: False" >> cabal.project.local \ + && cabal update \ + && cabal build all \ + && mkdir -p /root/.local/bin/ \ + && cp -p dist-newstyle/build/$(uname -m)-linux/ghc-${GHC_VERSION}/cardano-cli-${CLI_VERSION}/x/cardano-cli/build/cardano-cli/cardano-cli /root/.local/bin/ \ + && rm -rf /root/.cabal/packages \ + && rm -rf /usr/local/lib/ghc-${GHC_VERSION}/ /usr/local/share/doc/ghc-${GHC_VERSION}/ \ + && rm -rf /code/cardano-cli/dist-newstyle/ \ + && rm -rf /root/.cabal/store/ghc-${GHC_VERSION} + +FROM debian:bookworm-slim AS cardano-cli +ENV LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" +ENV PKG_CONFIG_PATH="/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH" +COPY --from=cardano-cli-build /usr/local/lib/ /usr/local/lib/ +COPY --from=cardano-cli-build /usr/local/include/ /usr/local/include/ +COPY --from=cardano-cli-build /root/.local/bin/cardano-* /usr/local/bin/ +RUN apt-get update -y && \ + apt-get install -y \ + bc \ + curl \ + iproute2 \ + jq \ + libffi8 \ + libgmp10 \ + liblmdb0 \ + libncursesw5 \ + libnuma1 \ + libsystemd0 \ + libssl3 \ + libtinfo6 \ + llvm-14-runtime \ + netbase \ + pkg-config \ + procps \ + sqlite3 \ + wget \ + zlib1g && \ + rm -rf /var/lib/apt/lists/* && \ + chmod +x /usr/local/bin/* +ENTRYPOINT ["/usr/local/bin/cardano-cli"]