diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0c0dff6..df8d88e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,14 +1,66 @@ name: Continuous Integration + on: pull_request: branches: - main + jobs: - build: - name: Build + build-docker: + name: Build Docker runs-on: ubuntu-latest steps: - name: Checkout repository - uses: actions/checkout@v2 + uses: actions/checkout@v4 + - name: Build service run: docker build . + + build-windows: + name: Build Windows executable + runs-on: windows-latest + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Setup Perl for Windows build + uses: shogo82148/actions-setup-perl@v1 + with: + perl-version: "5.40" + + - name: Install Perl dependencies for Windows build + run: | + cpanm --notest PAR::Packer + cpanm --notest Compress::Zlib + cpanm --notest Encode + cpanm --notest File::Basename + cpanm --notest File::Copy + cpanm --notest Getopt::Std + cpanm --notest HTTP::Cookies + cpanm --notest URI + cpanm --notest URI::Escape + cpanm --notest LWP::UserAgent + cpanm --notest LWP::ConnCache + cpanm --notest POSIX + cpanm --notest Time::Local + cpanm --notest Time::Piece + cpanm --notest JSON + cpanm --notest Sub::Util + + - name: Build Windows executable + run: pp -o zap2xml.exe zap2xml.pl + + - name: Copy entrypoint.bat + run: | + mkdir dist + copy .zap2xml-example dist\.zap2xml-example + copy entrypoint.bat dist\entrypoint.bat + copy zap2xml.exe dist\zap2xml.exe + shell: cmd + + - name: Upload Windows artifacts + uses: actions/upload-artifact@v4 + with: + name: zap2xml-windows + path: dist/ + retention-days: 1 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index d3d04ec..69278f7 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -7,14 +7,14 @@ on: jobs: build-tag-release: - name: Build, tag, and release Docker image + name: Build, tag, and release Docker image and Windows executable runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Setup release please - uses: google-github-actions/release-please-action@v2 + uses: googleapis/release-please-action@v4 id: release with: token: ${{ secrets.GITHUB_TOKEN }} @@ -22,6 +22,45 @@ jobs: changelog-path: CHANGELOG.md package-name: zap2xml + - name: Setup Perl for Windows build + if: ${{ steps.release.outputs.release_created }} + uses: shogo82148/actions-setup-perl@v1 + with: + perl-version: "5.40" + + - name: Install Perl dependencies for Windows build + if: ${{ steps.release.outputs.release_created }} + run: | + cpanm --notest PAR::Packer + cpanm --notest Compress::Zlib + cpanm --notest Encode + cpanm --notest File::Basename + cpanm --notest File::Copy + cpanm --notest Getopt::Std + cpanm --notest HTTP::Cookies + cpanm --notest URI + cpanm --notest URI::Escape + cpanm --notest LWP::UserAgent + cpanm --notest LWP::ConnCache + cpanm --notest POSIX + cpanm --notest Time::Local + cpanm --notest Time::Piece + cpanm --notest JSON + + - name: Build Windows executable + if: ${{ steps.release.outputs.release_created }} + run: pp -o zap2xml.exe zap2xml.pl + + - name: Upload Windows executable to release + if: ${{ steps.release.outputs.release_created }} + run: | + curl -X POST \ + -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + -H "Content-Type: application/octet-stream" \ + --data-binary @zap2xml.exe \ + "${{ steps.release.outputs.upload_url }}?name=zap2xml.exe&label=Windows%20Executable" + - name: Login into GitHub Container Registry if: ${{ steps.release.outputs.release_created }} run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin diff --git a/entrypoint.bat b/entrypoint.bat new file mode 100644 index 0000000..300df24 --- /dev/null +++ b/entrypoint.bat @@ -0,0 +1,11 @@ +@echo off +:loop +set DATESTR=%DATE% %TIME% +echo Running zap2xml.exe at %DATESTR% +zap2xml.exe %OPT_ARGS% +echo Last run time: %DATESTR% +echo Will run again in %SLEEPTIME% seconds +REM Default sleep time if not set +if "%SLEEPTIME%"=="" set SLEEPTIME=43200 +powershell -Command "Start-Sleep -Seconds %SLEEPTIME%" +goto loop