From 48936efa96ae17295be4e0a71be3294f0ec6aef8 Mon Sep 17 00:00:00 2001 From: Mathieu Deous Date: Mon, 2 May 2022 20:18:23 +0200 Subject: Make application go-install-able and create a docker image --- .github/workflows/docker.yml | 41 +++++++++++++++++++++++++++++++++++++++++ .github/workflows/release.yml | 40 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/test.yml | 19 +++++++++++++++---- 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/docker.yml create mode 100644 .github/workflows/release.yml (limited to '.github') diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..b44e0b7 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,41 @@ +name: Docker + +on: + push: + branches: + - master + tags: + - '*' + pull_request: + branches: + - master + +jobs: + + docker-image: + name: Build Image + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Setup docker + uses: docker/setup-buildx-action@v1 + + - name: Log into container registry + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build image + run: make docker + + - name: Test image + run: make docker-tests + + - name: Publish image + if: github.event_name != 'pull_request' + run: make docker-publish diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..6b1647a --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Release + +on: + push: + tags: + - '*' + +jobs: + + release: + name: Release + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: '^1.18' + + # apt repos don't have YARA v4.2, install it from git + - name: Install YARA + run: | + git clone --depth 1 https://github.com/virustotal/yara.git + cd yara + bash ./build.sh + sudo make install + cd .. + + - name: Build + run: make + + - name: Create release + uses: ncipollo/release-action@v1 + with: + artifacts: "php-malware-finder" + token: ${{ secrets.GITHUB_TOKEN }} + allowUpdates: true + omitBody: true diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f29e422..a3cbc35 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,17 +9,25 @@ on: - master jobs: + test: name: Test runs-on: ubuntu-latest + strategy: + matrix: + go_version: + - '~1.16' + - '~1.17' + - '^1.18' + steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Setup Go - uses: actions/setup-go@v2 + uses: actions/setup-go@v3 with: - go-version: '^1.17' + go-version: ${{ matrix.go_version }} # apt repos don't have YARA v4.2, install it from git - name: Install YARA @@ -32,4 +40,7 @@ jobs: - name: Run tests run: | - LD_LIBRARY_PATH=/usr/local/lib make tests + make + make tests + env: + LD_LIBRARY_PATH: /usr/local/lib -- cgit v1.3