diff --git a/.github/workflows/build-release-assets.yml b/.github/workflows/build-release-assets.yml index 113ba98..1fac569 100644 --- a/.github/workflows/build-release-assets.yml +++ b/.github/workflows/build-release-assets.yml @@ -2,39 +2,56 @@ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go name: Build Release Assets -on: - workflow_dispatch: +on: release: types: [published] + jobs: - releases-matrix: - name: Release Zip - runs-on: ubuntu-latest - strategy: - matrix: - make_directive: [zip-x86_64, zip-arm64] - steps: - - uses: actions/checkout@v3 - - name: set up Go - uses: actions/setup-go@v3 + build-release-x86_64: + runs-on: ubuntu-20.04 + if: startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 with: - go-version: 1.21 - - - name: make zip - run: make ${{ matrix.make_directive }} - - - name: upload artifact - env: - GH_TOKEN: ${{ secrets.RELEASE_ASSET_TOKEN }} - run: | - tag=$(gh release list --json tagName -q '.[0].tagName') - file=/tmp/newrelic-lambda-extension.arm64.zip - if [ -f /tmp/newrelic-lambda-extension.x86_64.zip ];then - file=/tmp/newrelic-lambda-extension.x86_64.zip - fi + go-version: '1.20' + cache-dependency-path: | + subdir/go.sum + tools/go.sum + - name: Build and archive x86_64 distribution + run: make zip-x86_64 + - name: Publish x86_64 release on GitHub + uses: softprops/action-gh-release@v1 + with: + files: /tmp/newrelic-lambda-extension.x86_64.zip + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ github.ref_name }} + name: "Release ${{ github.ref_name }}" + draft: false + prerelease: false - echo "uploading $file to release $tag" - gh release upload "$tag" "$file" - - + build-release-arm: + runs-on: ubuntu-20.04 + if: startsWith(github.ref, 'refs/tags/v') + steps: + - uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.20' + cache-dependency-path: | + subdir/go.sum + tools/go.sum + - name: Build and archive arm distribution + run: make zip-arm64 + - name: Publish zip-arm64 release on GitHub + uses: softprops/action-gh-release@v1 + with: + files: /tmp/newrelic-lambda-extension.arm64.zip + token: ${{ secrets.GITHUB_TOKEN }} + tag_name: ${{ github.ref_name }} + name: "Release ${{ github.ref_name }}" + draft: false + prerelease: false diff --git a/.github/workflows/build-test-coverage.yml b/.github/workflows/build-test-coverage.yml new file mode 100644 index 0000000..0db4f9e --- /dev/null +++ b/.github/workflows/build-test-coverage.yml @@ -0,0 +1,52 @@ +# This workflow will test and run code coverage for the golang project +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go + +name: Build Test Coverage +on: + pull_request: + push: + + +env: + TEST_RESULTS: /tmp/test-results + +jobs: + build-test: + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.20' + cache-dependency-path: | + subdir/go.sum + tools/go.sum + - name: Create test directory + run: mkdir -p $TEST_RESULTS + - name: Install gotestsum + run: go install gotest.tools/gotestsum@latest + - name: Run unit tests + run: | + PACKAGE_NAMES=$(go list ./... | xargs) + gotestsum --junitfile ${TEST_RESULTS}/gotestsum-report.xml -- $PACKAGE_NAMES + - name: Run build + run: make build + + + coverage: + runs-on: ubuntu-20.04 + needs: build-test + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Go + uses: actions/setup-go@v4 + with: + go-version: '1.20' + cache: true + - name: Generate coverage report + run: make coverage + - name: Upload coverage report + run: bash -c "$(curl -s https://codecov.io/bash)"