Skip to content
This repository has been archived by the owner on Nov 24, 2022. It is now read-only.

Commit

Permalink
build docker image and binary release [shipit]
Browse files Browse the repository at this point in the history
Signed-off-by: Merlin Ran <[email protected]>
  • Loading branch information
merlinran committed Jul 5, 2021
1 parent b5b234f commit 9e8ee9a
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 13 deletions.
92 changes: 92 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
name: Release
# this workflow pushes docker images to textile/bidbot for updates on main branch, any new tags, and commits with `[shipit]` in message.
# it also creates new releases with linux binaries on GitHub for any new tags.

on:
push:
branches:
- '**'
tags:
- 'v*'

jobs:
release:
if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || contains(github.event.head_commit.message, '[shipit]')
runs-on: ubuntu-latest
steps:
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"

- name: Docker meta
id: meta
uses: docker/metadata-action@v3
with:
images: textile/bidbot
tags: |
type=edge,branch=main
type=semver,pattern={{version}}
type=sha,prefix=sha-
- name: Checkout
uses: actions/checkout@v2

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v1

- name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Buildx patch
run: |
file="./Dockerfile"
echo "patching timestamp for $file"
touch "$file"
- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: .
builder: ${{ steps.buildx.outputs.name }}
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

- name: Cache Go resources for linux
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Build binary
if: startsWith(github.ref, 'refs/tags/v')
run: make build && mv bidbot bidbot-linux-amd64

- name: Create versioned release for linux
if: startsWith(github.ref, 'refs/tags/v')
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ github.token }}"
prerelease: false
files: |
LICENSE
bidbot-*
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Binaries for programs and plugins
/bidbot
*.exe
*.exe~
*.dll
Expand Down
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ COPY go.mod go.sum ./
RUN go mod download -x
COPY . .
RUN --mount=type=cache,target=/root/.cache/go-build \
BIN_BUILD_FLAGS="CGO_ENABLED=0 GOOS=linux" make build-bidbot
BIN_BUILD_FLAGS="CGO_ENABLED=0 GOOS=linux" make build

FROM alpine
COPY --from=builder /app/bidbot /app/bidbot
COPY --from=builder /app/cmd/bidbot/bin/container_daemon /app/start_bidbot
COPY --from=builder /app/bin/container_daemon /app/start_bidbot
WORKDIR /app

ENV BIDBOT_PATH /data/bidbot
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ lint: $(GOLANGCI_LINT)
$(GOLANGCI_LINT) run
.PHONYY: lint


build: $(GOVVV)
$(BIN_BUILD_FLAGS) go build -ldflags="${GOVVV_FLAGS}" ./...
$(BIN_BUILD_FLAGS) go build -ldflags="${GOVVV_FLAGS}" .
.PHONY: build

mocks: $(MOCKERY) clean-mocks
Expand Down
23 changes: 13 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@ Join us on our [public Slack channel](https://slack.textile.io/) for news, discu

## Table of Contents

- [Installation](#installation)
- [Getting Started](#getting-started)
- [Contributing](#contributing)
- [Changelog](#changelog)
- [License](#license)

## Getting Started

1. [Install Go 1.15 or newer](https://golang.org/doc/install)
2. Run following commands
```
## Installation
- **Prebuilt package**: See [release assets](https://github.com/textileio/bidbot/releases/latest)
- **Docker image**: See the `latest` tag on [Docker Hub](https://hub.docker.com/r/textile/bidbot/tags)
- **Build from the source** ([Go 1.15 or newer](https://golang.org/doc/install)):
```bash
git clone https://github.com/textileio/bidbot.git
cd bidbot
make install
bidbot init
```
3. The output will ask you to sign a token with the owner address of your miner.
4. Configure your _ask price_, other bid settings, and auction filters. See `bidbot help daemon` for details. You can edit the configuration file generated by `bidbot init` or use the equivalent flag for any given option.
5. Use the signature you generated above to start the daemon: `bidbot daemon --miner-addr [address] --wallet-addr-sig [signature]`
6. Good luck! Your `bidbot` will automatically bid in open deal auctions. If it wins an auction, the broker will automatically start making a deal with the Lotus wallet address used in step 3.

## Getting Started
1. `bidbot init`
1. The output will ask you to sign a token with the owner address of your miner.
1. Configure your _ask price_, other bid settings, and auction filters. See `bidbot help daemon` for details. You can edit the configuration file generated by `bidbot init` or use the equivalent flag for any given option.
1. Use the signature you generated above to start the daemon: `bidbot daemon --miner-addr [address] --wallet-addr-sig [signature]`
1. Good luck! Your `bidbot` will automatically bid in open deal auctions. If it wins an auction, the broker will automatically start making a deal with the Lotus wallet address used in step 1.

## Contributing

Expand Down

0 comments on commit 9e8ee9a

Please sign in to comment.