diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..afb2bfb --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,70 @@ +name: Release Binaries + +on: + push: + tags: + - "v*" + workflow_dispatch: + +permissions: + contents: write + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - run: bun install + + - name: Get version + id: pkg + run: echo "version=$(jq -r .version package.json)" >> $GITHUB_OUTPUT + + - name: Enforce tag matches version (on tag push) + if: startsWith(github.ref, 'refs/tags/v') + run: | + if [ "${{ github.ref_name }}" != "v${{ steps.pkg.outputs.version }}" ]; then + echo "::error::Git tag does not match package.json version" + exit 1 + fi + + - name: Decide release tag + id: meta + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + echo "tag=v${{ steps.pkg.outputs.version }}" >> $GITHUB_OUTPUT + else + echo "tag=${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + + - run: mkdir -p release + + - name: Build Linux x64 + run: bun build ./index.ts --compile --target=bun-linux-x64 --outfile release/pezi-bot-linux-x64 + + - name: Build Linux arm64 + run: bun build ./index.ts --compile --target=bun-linux-arm64 --outfile release/pezi-bot-linux-arm64 + + - name: Build macOS x64 + run: bun build ./index.ts --compile --target=bun-darwin-x64 --outfile release/pezi-bot-macos-x64 + + - name: Build macOS arm64 + run: bun build ./index.ts --compile --target=bun-darwin-arm64 --outfile release/pezi-bot-macos-arm64 + + - name: Build Windows x64 + run: bun build ./index.ts --compile --target=bun-windows-x64 --outfile release/pezi-bot-windows-x64.exe + + - name: Upload & Release + uses: softprops/action-gh-release@v2 + with: + tag_name: ${{ steps.meta.outputs.tag }} + name: ${{ steps.meta.outputs.tag }} + files: release/* + generate_release_notes: true + draft: false diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..cd7b21d --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,26 @@ +name: Tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v2 + with: + bun-version: latest + + - name: Install dependencies + run: bun install + + - name: Run tests + run: bun test --preload ./tests/setup.ts diff --git a/package.json b/package.json index b872def..5aa117e 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,11 @@ "name": "pezi-bot", "module": "index.ts", "type": "module", + "version": "1.0.0", + "author": "Bare7a ", + "license": "GPL-3.0-only", + "homepage": "https://github.com/Bare7a/pezi-bot", + "description": "Pezi Bot is the ultimate Twitch chatbot, offering points, minigames, and interactive commands to engage viewers and enhance your streams.", "scripts": { "start": "bun run index.ts", "build": "bun build ./index.ts --compile --outfile ./bin/pezi-bot", @@ -12,5 +17,27 @@ }, "peerDependencies": { "typescript": "^5.0.0" - } + }, + "repository": { + "type": "git", + "url": "https://github.com/Bare7a/pezi-bot" + }, + "engines": { + "bun": ">=1.3.0" + }, + "bin": { + "pezi-bot": "./bin/pezi-bot" + }, + "keywords": [ + "twitch", + "chatbot", + "bot", + "minigames", + "trivia", + "raffle", + "slots", + "dice", + "points", + "streaming" + ] }