Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
191 changes: 0 additions & 191 deletions .github/workflows/build.yml

This file was deleted.

126 changes: 126 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
name: release-or-pre-release

on:
push:
tags:
- "v*"

jobs:
decide:
runs-on: ubuntu-latest
outputs:
release_type: ${{ steps.set_type.outputs.release_type }}
version: ${{ steps.set_type.outputs.version }}
steps:
- name: Extract version and type
id: set_type
run: |
TAG="${GITHUB_REF#refs/tags/}"
echo "Detected tag: $TAG"

if [[ "$TAG" == *-pre-release ]]; then
echo "release_type=pre" >> $GITHUB_OUTPUT
echo "version=${TAG#v}" | sed 's/-pre-release$//' >> $GITHUB_OUTPUT
else
echo "release_type=final" >> $GITHUB_OUTPUT
echo "version=${TAG#v}" >> $GITHUB_OUTPUT
fi

build:
needs: decide
runs-on: ubuntu-latest
outputs:
image_tag: ${{ steps.set_tag.outputs.image_tag }}
steps:
- name: Checkout
uses: actions/checkout@v2

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

- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}

- name: Set image tag
id: set_tag
run: |
VERSION="${{ needs.decide.outputs.version }}"
if [ "${{ needs.decide.outputs.release_type }}" = "pre" ]; then
TAG="bcdb/bcn:${VERSION}-pre-release"
else
TAG="bcdb/bcn:${VERSION}"
fi
echo "image_tag=$TAG" >> $GITHUB_OUTPUT

- name: Build and Push Docker Image
run: |
VERSION="${{ needs.decide.outputs.version }}"
TAG="${{ steps.set_tag.outputs.image_tag }}"

echo "Building image: $TAG"

docker buildx build --platform linux/amd64,linux/arm64 \
--push \
--tag "$TAG" \
-f Dockerfile .

if [ "${{ needs.decide.outputs.release_type }}" = "final" ]; then
docker buildx build --platform linux/amd64,linux/arm64 \
--push \
--tag "bcdb/bcn:latest" \
--tag "bcdb/bcn:${VERSION}" \
-f Dockerfile .
fi

integration-tests:
needs: [decide, build]
runs-on: ubuntu-latest
strategy:
matrix:
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Pull temporary image
run: |
docker pull ${{ needs.build.outputs.image_tag }}

- name: Re-tag image for docker-compose
run: |
docker tag ${{ needs.build.outputs.image_tag }} bcdb:bcn

- name: Copy configuration files
working-directory: packages/node
run: |
cp chain-setup/LTC/regtest/.env.example .env
cp chain-setup/LTC/regtest/litecoin.conf.example litecoin.conf

- name: Set up Docker Compose
run: |
sudo apt-get update && sudo apt-get install -y docker-compose

- name: Install dependencies (npm install)
working-directory: packages/node
continue-on-error: true
run: |
npm install || echo "npm install failed, continuing..."

- name: Start services in regtest mode
working-directory: packages/node
run: |
npm run up &
sleep 20

- name: Run integration tests
working-directory: packages/node
run: |
sleep 30; npm run test

- name: Stop services
working-directory: packages/node
run: |
npm run down
2 changes: 1 addition & 1 deletion packages/chat/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
VITE_CHAIN=LTC
VITE_NETWORK=regtest
VITE_URL=http://127.0.0.1:1031
VITE_PATH="m/44'/0'/0'/0"
VITE_PATH=m/44'/1'/0'

# Application Port
VITE_PORT=1032
Expand Down
31 changes: 22 additions & 9 deletions packages/chat/scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { config } from 'dotenv'
import * as readline from 'node:readline/promises'
import { readFile, writeFile } from 'fs/promises'
import { stdin as input, stdout as output } from 'node:process'
import { Computer } from '@bitcoin-computer/lib'
import { ChatSc } from '../src/contracts/chat.js'
Expand Down Expand Up @@ -42,18 +43,30 @@ if (answer === 'n') {
console.log('\n * Deploying ChatSc contract...')
const chatModSpec = await computer.deploy(`export ${ChatSc}`)

console.log(`
Successfully deployed chat smart contract.
console.log(' \x1b[2m- Successfully deployed smart contract\x1b[0m')

-----------------
ACTION REQUIRED
-----------------
const answer2 = await rl.question('\nDo you want to update your .env files? \x1b[2m(y/n)\x1b[0m')
if (answer2 === 'n') {
console.log(`

(1) Update the following rows in your .env file.
-----------------
ACTION REQUIRED
-----------------

VITE_CHAT_MOD_SPEC\x1b[2m=${chatModSpec}\x1b[0m
(2) Run 'npm start' to start the application.
`)
(1) Update the following rows in your .env file.

VITE_CHAT_MOD_SPEC\x1b[2m=${chatModSpec}\x1b[0m
(2) Run 'npm start' to start the application.
`)
} else {
const file = '.env'
const lines = (await readFile(file, 'utf-8')).split('\n')
for (let i = 0; i < lines.length; i++) {
if (lines[i].startsWith('VITE_CHAT_MOD_SPEC')) lines[i] = `VITE_CHAT_MOD_SPEC=${chatModSpec}`
}
await writeFile(file, lines.join('\n'), 'utf-8')
console.log(' \x1b[2m- Successfully updated .env file\x1b[0m')
}
}

rl.close()
2 changes: 1 addition & 1 deletion packages/chess-app/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ VITE_CHAIN=LTC
VITE_NETWORK=regtest
VITE_URL=http://127.0.0.1:1031
VITE_API_BASE_URL=http://127.0.0.1:4000
VITE_PATH="m/44'/0'/0'/0"
VITE_PATH=m/44'/1'/0'

# Application Port
VITE_PORT=1032
Expand Down
2 changes: 1 addition & 1 deletion packages/chess-server/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ VITE_CHAIN=LTC
VITE_NETWORK=regtest
VITE_URL=http://127.0.0.1:1031
VITE_API_BASE_URL=http://127.0.0.1:4000
VITE_PATH="m/44'/0'/0'/0"
VITE_PATH=m/44'/1'/0'

# Application Port
VITE_PORT=1032
Expand Down
Loading