diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..34696b4 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,54 @@ +name: Build and Release + +on: push + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [arm64, armv7h] + + steps: + - uses: actions/checkout@v4 + + - name: Generate version + id: version + run: | + # Generate semantic version based on date and run number + VERSION="0.1.${{ github.run_number }}" + echo "version=${VERSION}" >> $GITHUB_OUTPUT + echo "Generated version: ${VERSION}" + + - name: Set up Go + uses: actions/setup-go@v4 + with: + go-version: '1.21' + + - name: Install Qt dependencies + run: | + sudo apt-get update + sudo apt-get install -y qt6-tools-dev qttools5-dev + + - name: Build project for ${{ matrix.arch }} + run: | + chmod +x build.sh + ./build.sh ${{ matrix.arch }} + + - name: Create release archive + run: | + ARCH=${{ matrix.arch }} + VERSION=${{ steps.version.outputs.version }} + ZIP_NAME="reMarkdown-${ARCH}-${VERSION}.zip" + cd rmd + zip -r "../${ZIP_NAME}" backend manifest.json resources.rcc icon.png + cd .. + echo "ZIP_FILE=${ZIP_NAME}" >> $GITHUB_ENV + + - name: Upload release assets + uses: softprops/action-gh-release@v1 + with: + tag_name: v${{ steps.version.outputs.version }} + files: ${{ env.ZIP_FILE }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/build.sh b/build.sh index 18a6e5f..b192939 100755 --- a/build.sh +++ b/build.sh @@ -1,8 +1,36 @@ #!/bin/bash + +# Default to arm64 if no architecture is specified +ARCH=${1:-arm64} + +# Validate architecture +if [[ "$ARCH" != "arm64" && "$ARCH" != "armv7h" ]]; then + echo "Error: Unsupported architecture '$ARCH'. Supported: arm64, armv7h" + exit 1 +fi + +echo "Building for architecture: $ARCH" + rm -rf rmd mkdir -p rmd/backend cp manifest.json rmd cp icon.png rmd rcc --binary -o rmd/resources.rcc application.qrc -GOOS=linux GOARCH=arm64 go build . + +# Build the Go binary for the specified architecture +if [[ "$ARCH" == "armv7h" ]]; then + # armv7h uses GOARCH=arm with GOARM=7 + GOOS=linux GOARCH=arm GOARM=7 go build -o remarkdown . +else + # arm64 maps directly + GOOS=linux GOARCH=$ARCH go build -o remarkdown . +fi + +if [ ! -f remarkdown ]; then + echo "Error: Build failed - remarkdown binary not created" + exit 1 +fi + cp remarkdown rmd/backend/entry + +echo "Build completed successfully for $ARCH"