diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 6779348..9fc81e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -5,8 +5,12 @@ on: branches: - '**' +env: + VERSION: v1.${{ github.run_number }}.0 + jobs: - build_and_release: + build: + name: Build on ${{ matrix.os }} runs-on: ${{ matrix.os }} strategy: matrix: @@ -15,14 +19,80 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 + - name: Set up Build Environment + # For Windows, ensure Make is available. You might need to install it or use a different build tool. + if: runner.os == 'Windows' + run: | + choco install make + shell: pwsh + + - name: Install Dependencies + run: | + # Add any dependencies installation steps here + echo "Installing dependencies..." + - name: Build run: make + shell: bash + + - name: Archive Binary + run: | + mkdir -p artifacts + # Adjust 'mbox2eml' to your actual binary name + if [ "${{ runner.os }}" == "Windows" ]; then + cp mbox2eml.exe artifacts/mbox2eml-windows.exe + elif [ "${{ runner.os }}" == "macOS" ]; then + cp mbox2eml artifacts/mbox2eml-macos + else + cp mbox2eml artifacts/mbox2eml-linux + fi + shell: bash + if: runner.os != 'Windows' + + - name: Archive Binary (Windows) + run: | + mkdir artifacts + cp mbox2eml.exe artifacts/mbox2eml-windows.exe + shell: bash + if: runner.os == 'Windows' + + - name: Upload Artifact + uses: actions/upload-artifact@v3 + with: + name: ${{ matrix.os }}-binary + path: artifacts/ + + release: + name: Create GitHub Release + runs-on: ubuntu-latest + needs: build + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Download Artifacts + uses: actions/download-artifact@v3 + with: + path: release-binaries - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.VERSION }} + release_name: Release ${{ env.VERSION }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload Release Assets uses: softprops/action-gh-release@v1 with: - tag_name: 'build-${{ github.run_number }}' - release_name: 'Build ${{ github.run_number }}' - files: 'mbox2eml' # Replace 'myprogram' with your binary's name + tag_name: ${{ env.VERSION }} + files: | + release-binaries/ubuntu-latest-binary/mbox2eml-linux + release-binaries/macos-latest-binary/mbox2eml-macos + release-binaries/windows-latest-binary/mbox2eml-windows.exe env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}