From d5f8ce597cc24bf8817b251e79ee134d058c2ae7 Mon Sep 17 00:00:00 2001 From: Dave Shanley Date: Fri, 22 Jul 2022 16:09:16 -0400 Subject: [PATCH] Working through new build for pipeline. trying out a new build and publish mechanism --- .github/workflows/build.yaml | 67 ++++++++++--- .github/workflows/docker-build-push.yml | 86 ++++++++-------- .github/workflows/goreleaser.yaml | 78 +++++++-------- .github/workflows/label-check.yaml | 16 +++ .github/workflows/npm-publish.yml | 42 ++++---- .github/workflows/publish.yaml | 69 +++++++++++++ .github/workflows/tag.yaml | 59 +++++++++++ .github/workflows/vaccum-postmerge.yml | 126 ++++++++++++------------ package-lock.json | 4 +- package.json | 2 +- 10 files changed, 367 insertions(+), 182 deletions(-) create mode 100644 .github/workflows/label-check.yaml create mode 100644 .github/workflows/publish.yaml create mode 100644 .github/workflows/tag.yaml diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 2ff342ac..e1ac4847 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -1,12 +1,12 @@ name: Build -on: workflow_dispatch -# push: -# branches: -# - main -# pull_request: -# branches: -# - main +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: build: @@ -31,12 +31,53 @@ jobs: fi - name: Build run: make build - - # REMOVE WHEN RESOLVED - # 1) https://github.com/golangci/golangci-lint-action/issues/135 - # 2) https://github.com/golangci/golangci-lint-action/issues/81 - name: Clean modcache run: go clean -modcache + - name: Lint + uses: golangci/golangci-lint-action@v2 + - name: Coverage + run: | + go get github.com/axw/gocov/gocov + go get github.com/AlekSi/gocov-xml + go install github.com/axw/gocov/gocov + go install github.com/AlekSi/gocov-xml + - run: | + go test -v -coverprofile cover.out ./... + gocov convert cover.out | gocov-xml > coverage.xml + - uses: codecov/codecov-action@v1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + files: ./coverage.xml + flags: unittests + fail_ci_if_error: true + verbose: true + + build-report-ui: + runs-on: ubuntu-20.04 + strategy: + matrix: + node-version: [ 16.x, 18.x ] + steps: + - uses: actions/checkout@v3 + name: Checkout repository + + - name: setup node ${{matrix.node-version}} + uses: actions/setup-node@v3 + with: + node-version: ${{matrix.node-version}} + + - name: Install yarn + run: yarn install + working-directory: html-report/ui + + - name: Build + run: yarn build + working-directory: html-report/ui + + - name: Test + run: yarn test + working-directory: html-report/ui - - name: Lint Project - uses: golangci/golangci-lint-action@v2 \ No newline at end of file + - name: Lint + run: yarn lint + working-directory: html-report/ui \ No newline at end of file diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 8ec4bafb..2da24628 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -1,43 +1,43 @@ -name: Publish Docker image - -on: workflow_dispatch - -jobs: - push_to_registries: - name: Push Docker image to multiple registries - runs-on: ubuntu-latest - permissions: - packages: write - contents: read - steps: - - name: Check out the repo - uses: actions/checkout@v3 - - - name: Log in to Docker Hub - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - - name: Log in to the Container registry - uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 - with: - images: | - dshanley/vacuum - ghcr.io/${{ github.repository }} - - - name: Build and push Docker images - uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file +#name: Publish Docker image +# +#on: workflow_dispatch +# +#jobs: +# push_to_registries: +# name: Push Docker image to multiple registries +# runs-on: ubuntu-latest +# permissions: +# packages: write +# contents: read +# steps: +# - name: Check out the repo +# uses: actions/checkout@v3 +# +# - name: Log in to Docker Hub +# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 +# with: +# username: ${{ secrets.DOCKER_USERNAME }} +# password: ${{ secrets.DOCKER_PASSWORD }} +# +# - name: Log in to the Container registry +# uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 +# with: +# registry: ghcr.io +# username: ${{ github.actor }} +# password: ${{ secrets.GITHUB_TOKEN }} +# +# - name: Extract metadata (tags, labels) for Docker +# id: meta +# uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 +# with: +# images: | +# dshanley/vacuum +# ghcr.io/${{ github.repository }} +# +# - name: Build and push Docker images +# uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc +# with: +# context: . +# push: true +# tags: ${{ steps.meta.outputs.tags }} +# labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/goreleaser.yaml b/.github/workflows/goreleaser.yaml index 1e0b6fa6..ab166cc1 100644 --- a/.github/workflows/goreleaser.yaml +++ b/.github/workflows/goreleaser.yaml @@ -1,39 +1,39 @@ -name: goreleaser - -on: - push: - # run only against tags - tags: - - '*' - -permissions: - contents: write - # packages: write - # issues: write - -jobs: - goreleaser: - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - with: - fetch-depth: 0 - - - name: Fetch all tags - run: git fetch --force --tags - - - name: Set up Go - uses: actions/setup-go@v2 - with: - go-version: 1.18 - - - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v2 - with: - distribution: goreleaser - version: latest - args: release --rm-dist - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file +#name: goreleaser +# +#on: +# push: +# # run only against tags +# tags: +# - '*' +# +#permissions: +# contents: write +# # packages: write +# # issues: write +# +#jobs: +# goreleaser: +# runs-on: ubuntu-latest +# steps: +# - +# name: Checkout +# uses: actions/checkout@v2 +# with: +# fetch-depth: 0 +# - +# name: Fetch all tags +# run: git fetch --force --tags +# - +# name: Set up Go +# uses: actions/setup-go@v2 +# with: +# go-version: 1.18 +# - +# name: Run GoReleaser +# uses: goreleaser/goreleaser-action@v2 +# with: +# distribution: goreleaser +# version: latest +# args: release --rm-dist +# env: +# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/label-check.yaml b/.github/workflows/label-check.yaml new file mode 100644 index 00000000..09db1ff7 --- /dev/null +++ b/.github/workflows/label-check.yaml @@ -0,0 +1,16 @@ +name: Release Label Check + +on: + pull_request_target: + types: [opened, labeled, unlabeled, synchronize] + +jobs: + label-check: + runs-on: ubuntu-latest + steps: + - uses: jesusvasquez333/verify-pr-label-action@v1.4.0 + with: + github-token: "${{ secrets.GITHUB_TOKEN }}" + valid-labels: "release/patch, release/minor, release/major" + pull-request-number: '${{ github.event.pull_request.number }}' + disable-reviews: true \ No newline at end of file diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 5339963d..8c179ee3 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -1,21 +1,21 @@ -name: "NPM Publish" - -on: - push: - # run only against tags - tags: - - '*' -jobs: - publish: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - # Setup .npmrc file to publish to npm - - uses: actions/setup-node@v3 - with: - node-version: '16.x' - registry-url: 'https://registry.npmjs.org' - - run: npm ci - - run: npm publish - env: - NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file +#name: "NPM Publish" +# +#on: +# push: +# # run only against tags +# tags: +# - '*' +#jobs: +# publish: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# # Setup .npmrc file to publish to npm +# - uses: actions/setup-node@v3 +# with: +# node-version: '16.x' +# registry-url: 'https://registry.npmjs.org' +# - run: npm ci +# - run: npm publish +# env: +# NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml new file mode 100644 index 00000000..38d4dc7c --- /dev/null +++ b/.github/workflows/publish.yaml @@ -0,0 +1,69 @@ +name: Publish + +on: + repository_dispatch: + types: [publish-event] + +jobs: + release_and_brew: + name: Release and bump homebrew version + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Set up Go + uses: actions/setup-go@v2 + id: go + with: + go-version: ^1.16 + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GH_PAT }} + + publish_npm: + name: Publish to NPM + needs: release_and_brew + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set version + id: vars + run: echo ::set-output name=tag::${GITHUB_REF#refs/*/} + + - name: Check version + run: echo "Version ${{ github.event.client_payload.new-tag }}" + + - name: Use Node.js 16 + uses: actions/setup-node@v1 + with: + node-version: 16 + registry-url: https://registry.npmjs.org/ + + - name: Setup Git user + run: | + git config --global user.name "Github Bot" + git config --global user.email "github-bot@quobix.com" + - name: Create .npmrc file + run: echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > .npmrc + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Bump NPM version + run: npm --no-git-tag-version --allow-same-version version ${{ github.event.client_payload.new-tag }} + + - name: NPM publish + run: npm publish --access public + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/tag.yaml b/.github/workflows/tag.yaml new file mode 100644 index 00000000..0d4041fa --- /dev/null +++ b/.github/workflows/tag.yaml @@ -0,0 +1,59 @@ +name: Tag + +on: + push: + branches: + - main + +jobs: + tag: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - uses: actions-ecosystem/action-get-merged-pull-request@v1 + id: get-merged-pull-request + with: + github_token: ${{ secrets.GH_PAT }} + + - uses: actions-ecosystem/action-release-label@v1 + id: release-label + if: ${{ steps.get-merged-pull-request.outputs.title != null }} + with: + github_token: ${{ secrets.GH_PAT }} + labels: ${{ steps.get-merged-pull-request.outputs.labels }} + + - uses: actions-ecosystem/action-get-latest-tag@v1 + id: get-latest-tag + if: ${{ steps.release-label.outputs.level != null }} + with: + semver_only: true + + - uses: actions-ecosystem/action-bump-semver@v1 + id: bump-semver + if: ${{ steps.release-label.outputs.level != null }} + with: + current_version: ${{ steps.get-latest-tag.outputs.tag }} + level: ${{ steps.release-label.outputs.level }} + + - uses: actions-ecosystem/action-regex-match@v2 + id: regex-match + if: ${{ steps.bump-semver.outputs.new_version != null }} + with: + text: ${{ steps.get-merged-pull-request.outputs.body }} + regex: '```release_note([\s\S]*)```' + + - uses: actions-ecosystem/action-push-tag@v1 + if: ${{ steps.bump-semver.outputs.new_version != null }} + with: + tag: ${{ steps.bump-semver.outputs.new_version }} + message: "${{ steps.bump-semver.outputs.new_version }}: PR #${{ steps.get-merged-pull-request.outputs.number }} ${{ steps.get-merged-pull-request.outputs.title }}" + + - uses: peter-evans/repository-dispatch@v1 + if: ${{ steps.bump-semver.outputs.new_version != null }} + with: + token: ${{ secrets.GH_PAT }} + repository: daveshanley/vacuum + + event-type: publish-event + client-payload: '{"new-tag": "${{ steps.bump-semver.outputs.new_version }}", "release-notes": "${{ steps.regex-match.outputs.group1 }}"}' \ No newline at end of file diff --git a/.github/workflows/vaccum-postmerge.yml b/.github/workflows/vaccum-postmerge.yml index 65201a21..6d5462ff 100644 --- a/.github/workflows/vaccum-postmerge.yml +++ b/.github/workflows/vaccum-postmerge.yml @@ -1,63 +1,63 @@ -name: vacuum pipeline - -on: - push: - branches: - - main -jobs: - test: - runs-on: ubuntu-20.04 - steps: - - name: Set up repo - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 - with: - go-version: '^1.16' - - run: go get ./... - - run: | - go get github.com/axw/gocov/gocov - go get github.com/AlekSi/gocov-xml - go install github.com/axw/gocov/gocov - go install github.com/AlekSi/gocov-xml - - run: | - go test -v -coverprofile cover.out ./... - gocov convert cover.out | gocov-xml > coverage.xml - - uses: codecov/codecov-action@v1 - with: - token: ${{ secrets.CODECOV_TOKEN }} - files: ./coverage.xml - flags: unittests - fail_ci_if_error: true - verbose: true - - - build-report-ui: - runs-on: ubuntu-20.04 - strategy: - matrix: - node-version: [ 16.x, 18.x ] - steps: - - uses: actions/checkout@v3 - name: Checkout repository - - - name: setup node ${{matrix.node-version}} - uses: actions/setup-node@v3 - with: - node-version: ${{matrix.node-version}} - - - name: Install yarn - run: yarn install - working-directory: html-report/ui - - - name: Build - run: yarn build - working-directory: html-report/ui - - - name: Test - run: yarn test - working-directory: html-report/ui - - - name: Lint - run: yarn lint - working-directory: html-report/ui - +#name: vacuum pipeline +# +#on: +# push: +# branches: +# - main +#jobs: +# test: +# runs-on: ubuntu-20.04 +# steps: +# - name: Set up repo +# uses: actions/checkout@v3 +# - uses: actions/setup-go@v2 +# with: +# go-version: '^1.16' +# - run: go get ./... +# - run: | +# go get github.com/axw/gocov/gocov +# go get github.com/AlekSi/gocov-xml +# go install github.com/axw/gocov/gocov +# go install github.com/AlekSi/gocov-xml +# - run: | +# go test -v -coverprofile cover.out ./... +# gocov convert cover.out | gocov-xml > coverage.xml +# - uses: codecov/codecov-action@v1 +# with: +# token: ${{ secrets.CODECOV_TOKEN }} +# files: ./coverage.xml +# flags: unittests +# fail_ci_if_error: true +# verbose: true +# +# +# build-report-ui: +# runs-on: ubuntu-20.04 +# strategy: +# matrix: +# node-version: [ 16.x, 18.x ] +# steps: +# - uses: actions/checkout@v3 +# name: Checkout repository +# +# - name: setup node ${{matrix.node-version}} +# uses: actions/setup-node@v3 +# with: +# node-version: ${{matrix.node-version}} +# +# - name: Install yarn +# run: yarn install +# working-directory: html-report/ui +# +# - name: Build +# run: yarn build +# working-directory: html-report/ui +# +# - name: Test +# run: yarn test +# working-directory: html-report/ui +# +# - name: Lint +# run: yarn lint +# working-directory: html-report/ui +# diff --git a/package-lock.json b/package-lock.json index 753d3eca..ec2cc2bc 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quobix/vacuum", - "version": "0.0.12", + "version": "0.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quobix/vacuum", - "version": "0.0.12", + "version": "0.0.0", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 55c8be44..342a2f91 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quobix/vacuum", - "version": "0.0.18", + "version": "0.0.0", "description": "The world's fastest, most scalable and complete OpenAPI parser", "type": "module", "author": "Dave Shanley",