Add LICENSE, update goreleaser and CI for Ditto-OS/Ditto #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Ditto | |
| on: | |
| push: | |
| branches: [main, master] | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: [main, master] | |
| env: | |
| GO_VERSION: '1.21' | |
| jobs: | |
| # Build for Windows | |
| build-windows: | |
| runs-on: windows-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Tidy modules | |
| run: go mod tidy | |
| - name: Build Windows binary | |
| run: | | |
| go build -o Ditto.exe -ldflags "-s -w -X main.version=${{ github.ref_name }}" ./cmd/ditto | |
| - name: Test Windows binary | |
| run: | | |
| .\Ditto.exe version | |
| .\Ditto.exe languages | |
| - name: Upload Windows artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Ditto-windows-amd64 | |
| path: Ditto.exe | |
| retention-days: 30 | |
| # Build for macOS (Intel) | |
| build-macos-intel: | |
| runs-on: macos-13 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Tidy modules | |
| run: go mod tidy | |
| - name: Build macOS Intel binary | |
| run: | | |
| go build -o Ditto-macos-amd64 -ldflags "-s -w -X main.version=${{ github.ref_name }}" ./cmd/ditto | |
| - name: Test macOS Intel binary | |
| run: | | |
| chmod +x Ditto-macos-amd64 | |
| ./Ditto-macos-amd64 version | |
| ./Ditto-macos-amd64 languages | |
| - name: Upload macOS Intel artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Ditto-macos-amd64 | |
| path: Ditto-macos-amd64 | |
| retention-days: 30 | |
| # Build for macOS (Apple Silicon) | |
| build-macos-arm: | |
| runs-on: macos-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Tidy modules | |
| run: go mod tidy | |
| - name: Build macOS ARM binary | |
| run: | | |
| go build -o Ditto-macos-arm64 -ldflags "-s -w -X main.version=${{ github.ref_name }}" ./cmd/ditto | |
| - name: Test macOS ARM binary | |
| run: | | |
| chmod +x Ditto-macos-arm64 | |
| ./Ditto-macos-arm64 version | |
| ./Ditto-macos-arm64 languages | |
| - name: Upload macOS ARM artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Ditto-macos-arm64 | |
| path: Ditto-macos-arm64 | |
| retention-days: 30 | |
| # Build for Linux | |
| build-linux: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Tidy modules | |
| run: go mod tidy | |
| - name: Build Linux binary | |
| run: | | |
| go build -o Ditto-linux-amd64 -ldflags "-s -w -X main.version=${{ github.ref_name }}" ./cmd/ditto | |
| - name: Test Linux binary | |
| run: | | |
| chmod +x Ditto-linux-amd64 | |
| ./Ditto-linux-amd64 version | |
| ./Ditto-linux-amd64 languages | |
| - name: Upload Linux artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Ditto-linux-amd64 | |
| path: Ditto-linux-amd64 | |
| retention-days: 30 | |
| # Cross-compile for all platforms (alternative single job) | |
| build-cross: | |
| runs-on: ubuntu-latest | |
| needs: [build-windows, build-macos-intel, build-macos-arm, build-linux] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Tidy modules | |
| run: go mod tidy | |
| - name: Create dist directory | |
| run: mkdir -p dist | |
| - name: Build all platforms | |
| run: | | |
| # Windows | |
| GOOS=windows GOARCH=amd64 go build -o dist/Ditto-windows-amd64.exe -ldflags "-s -w" ./cmd/ditto | |
| GOOS=windows GOARCH=arm64 go build -o dist/Ditto-windows-arm64.exe -ldflags "-s -w" ./cmd/ditto | |
| # macOS | |
| GOOS=darwin GOARCH=amd64 go build -o dist/Ditto-macos-amd64 -ldflags "-s -w" ./cmd/ditto | |
| GOOS=darwin GOARCH=arm64 go build -o dist/Ditto-macos-arm64 -ldflags "-s -w" ./cmd/ditto | |
| # Linux | |
| GOOS=linux GOARCH=amd64 go build -o dist/Ditto-linux-amd64 -ldflags "-s -w" ./cmd/ditto | |
| GOOS=linux GOARCH=arm64 go build -o dist/Ditto-linux-arm64 -ldflags "-s -w" ./cmd/ditto | |
| # Create checksums | |
| cd dist && sha256sum * > checksums.txt | |
| - name: Upload all artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Ditto-all-platforms | |
| path: dist/ | |
| retention-days: 30 | |
| # Create GitHub Release (only on tags) | |
| create-release: | |
| runs-on: ubuntu-latest | |
| needs: [build-cross] | |
| if: startsWith(github.ref, 'refs/tags/v') | |
| steps: | |
| - name: Download all artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: Ditto-all-platforms | |
| path: dist/ | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: dist/* | |
| generate_release_notes: true | |
| draft: false | |
| prerelease: false | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| # Run tests | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Tidy modules | |
| run: go mod tidy | |
| - name: Run tests | |
| run: go test ./... | |
| - name: Build and run examples | |
| run: | | |
| go build -o Ditto ./cmd/ditto | |
| ./Ditto run examples/hello.py | |
| ./Ditto run examples/hello.js | |
| ./Ditto run examples/hello.lua | |
| ./Ditto run examples/query.sql | |
| # Code quality checks | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: ${{ env.GO_VERSION }} | |
| cache: false | |
| - name: Tidy modules | |
| run: go mod tidy | |
| - name: Run go fmt | |
| run: | | |
| output=$(gofmt -l .) | |
| if [ -n "$output" ]; then | |
| echo "Unformatted files found:" | |
| echo "$output" | |
| exit 1 | |
| fi | |
| - name: Run go vet | |
| run: go vet ./... | |
| - name: Run go mod tidy check | |
| run: | | |
| git diff --exit-code go.mod go.sum || (echo "go.mod/go.sum not tidy" && exit 1) |