From c8238189b38845eb8ce325d1b6aba6b4f0d9233d Mon Sep 17 00:00:00 2001 From: clambin Date: Tue, 15 Mar 2022 14:14:50 +0100 Subject: [PATCH] build: move to common workflows --- .github/workflows/analysis.yml | 18 ---- .github/workflows/build.yml | 93 ++------------------ .github/workflows/release.yml | 115 +++---------------------- .github/workflows/test.yml | 16 +--- .github/workflows/vulnerabilities.yaml | 9 ++ 5 files changed, 27 insertions(+), 224 deletions(-) delete mode 100644 .github/workflows/analysis.yml create mode 100644 .github/workflows/vulnerabilities.yaml diff --git a/.github/workflows/analysis.yml b/.github/workflows/analysis.yml deleted file mode 100644 index 1ddac32..0000000 --- a/.github/workflows/analysis.yml +++ /dev/null @@ -1,18 +0,0 @@ -name: Analysis - -on: - push: - pull_request: - -jobs: - analyse: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: install dependencies - run: go install golang.org/x/lint/golint@latest - - run: golint ./... - - run: go vet ./... \ No newline at end of file diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a0ab3cd..ec920a0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,94 +4,13 @@ on: push: branches: - master - - refactor - - fix jobs: test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: test - run: | - go test ./... -race -coverprofile=coverage.txt -covermode=atomic - - uses: codecov/codecov-action@v2.1.0 - with: - file: coverage.txt - token: ${{ secrets.CODECOV_TOKEN }} + uses: clambin/workflows/.github/workflows/test.yaml@main build: - needs: test - runs-on: ubuntu-latest - strategy: - matrix: - target: [ pinger ] - platform: [ linux ] - arch: [ amd64, arm, arm64 ] - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: Version number - id: vars - run: echo ::set-output name=tag::${GITHUB_REF##*/} - - name: build - env: - TARGET: ${{ matrix.target }} - GOOS: ${{ matrix.platform }} - GOARCH: ${{ matrix.arch }} - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} - run: | - go build \ - -ldflags "-X github.com/clambin/pinger/version.BuildVersion=$RELEASE_VERSION" \ - -o bld/$TARGET-$GOOS-$GOARCH \ - $TARGET.go - - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.target }}-${{ matrix.platform }}-${{ matrix.arch }} - path: ./bld/* - docker: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/download-artifact@v2 - with: - name: pinger-linux-arm - path: ./bld - - uses: actions/download-artifact@v2 - with: - name: pinger-linux-arm64 - path: ./bld - - uses: actions/download-artifact@v2 - with: - name: pinger-linux-amd64 - path: ./bld - - name: Fix permissions - run: chmod +x bld/* - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1.6.0 - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/metadata-action@v3.6.2 - id: pinger_meta - with: - images: ghcr.io/clambin/pinger - tags: | - type=sha - type=semver,pattern={{version}} - - name: docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./build/Dockerfile - platforms: linux/amd64,linux/arm,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.pinger_meta.outputs.tags }} - labels: ${{ steps.pinger_meta.outputs.labels }} \ No newline at end of file + needs: + - test + uses: clambin/workflows/.github/workflows/build.yaml@main + with: + target: pinger diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1523bac..9ebeba7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,112 +3,19 @@ name: Release on: push: tags: - - '*' + - 'v*' jobs: test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: test - run: | - go test ./... -race -coverprofile=coverage.txt -covermode=atomic - - uses: codecov/codecov-action@v2.1.0 - with: - file: coverage.txt - token: ${{ secrets.CODECOV_TOKEN }} + uses: clambin/workflows/.github/workflows/test.yaml@main build: - needs: test - runs-on: ubuntu-latest - strategy: - matrix: - target: [ pinger ] - platform: [ linux ] - arch: [ amd64, arm, arm64 ] - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: Version number - id: vars - run: echo ::set-output name=tag::${GITHUB_REF##*/} - - name: build - env: - TARGET: ${{ matrix.target }} - GOOS: ${{ matrix.platform }} - GOARCH: ${{ matrix.arch }} - RELEASE_VERSION: ${{ steps.vars.outputs.tag }} - run: | - go build \ - -ldflags "-X github.com/clambin/pinger/version.BuildVersion=$RELEASE_VERSION" \ - -o bld/$TARGET-$GOOS-$GOARCH \ - $TARGET.go - - uses: actions/upload-artifact@v2 - with: - name: ${{ matrix.target }}-${{ matrix.platform }}-${{ matrix.arch }} - path: ./bld/* - docker: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/download-artifact@v2 - with: - name: pinger-linux-arm - path: ./bld - - uses: actions/download-artifact@v2 - with: - name: pinger-linux-arm64 - path: ./bld - - uses: actions/download-artifact@v2 - with: - name: pinger-linux-amd64 - path: ./bld - - name: Fix permissions - run: chmod +x bld/* - - uses: docker/setup-qemu-action@v1 - - uses: docker/setup-buildx-action@v1.6.0 - - uses: docker/login-action@v1 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - uses: docker/metadata-action@v3.6.2 - id: pinger_meta - with: - images: ghcr.io/clambin/pinger - tags: | - type=sha - type=semver,pattern={{version}} - - name: docker image - uses: docker/build-push-action@v2 - with: - context: . - file: ./build/Dockerfile - platforms: linux/amd64,linux/arm,linux/arm64 - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.pinger_meta.outputs.tags }} - labels: ${{ steps.pinger_meta.outputs.labels }} - publish: - needs: build - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/download-artifact@v2 - with: - path: ./artifacts - - name: Move binaries into place - run: | - mkdir bld - mv artifacts/*/* bld - - uses: marvinpinto/action-automatic-releases@v1.2.1 - with: - repo_token: "${{ secrets.GITHUB_TOKEN }}" - prerelease: false - files: | - bld/* + needs: + - test + uses: clambin/workflows/.github/workflows/build.yaml@main + with: + target: pinger + release: + needs: + - build + uses: clambin/workflows/.github/workflows/release.yaml@main diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d6f444f..74f8b2a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,22 +4,8 @@ on: push: branches-ignore: - master - - refactor - - fix pull_request_target: jobs: test: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2.4.0 - - uses: actions/setup-go@v2 - with: - go-version: 1.17 - - name: test - run: | - go test ./... -race -coverprofile=coverage.txt -covermode=atomic - - uses: codecov/codecov-action@v2.1.0 - with: - file: coverage.txt - token: ${{ secrets.CODECOV_TOKEN }} \ No newline at end of file + uses: clambin/workflows/.github/workflows/test.yaml@main diff --git a/.github/workflows/vulnerabilities.yaml b/.github/workflows/vulnerabilities.yaml new file mode 100644 index 0000000..9cb4cee --- /dev/null +++ b/.github/workflows/vulnerabilities.yaml @@ -0,0 +1,9 @@ +name: Vulnerabilities + +on: + schedule: + - cron: '23 3 * * 6' + +jobs: + vulnerabilities: + uses: clambin/workflows/.github/workflows/vulnerabilities.yaml@main