From 330d2835a819d8b0488c7b01ded585cc03100891 Mon Sep 17 00:00:00 2001 From: Tong Sun Date: Mon, 5 Jul 2021 20:28:20 -0400 Subject: [PATCH] - [+] use GH actions for CD instead of defunct bintray --- .github/workflows/codeql-analysis.yml | 76 ++++++++++++++++++++++++++ .github/workflows/go-release-build.yml | 45 +++++++++++++++ .goreleaser.yml | 31 +++++++++++ .travis.yml | 51 ----------------- bintray-bin.json | 27 --------- bintray-pkg.json | 34 ------------ 6 files changed, 152 insertions(+), 112 deletions(-) create mode 100644 .github/workflows/codeql-analysis.yml create mode 100644 .github/workflows/go-release-build.yml create mode 100644 .goreleaser.yml delete mode 100644 .travis.yml delete mode 100644 bintray-bin.json delete mode 100644 bintray-pkg.json diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..56dff65 --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,76 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + paths-ignore: + - '**/*.md' + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + paths-ignore: + - '**/*.md' + schedule: + # The default branch at 14:32 UTC on the 1st of every month + - cron: '32 14 1 * *' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below) + - name: Autobuild + uses: github/codeql-action/autobuild@v1 + + # ℹī¸ Command-line programs to run using the OS shell. + # 📚 https://git.io/JvXDl + + # ✏ī¸ If the Autobuild fails above, remove it and uncomment the following three lines + # and modify them (or add more) to build your code if your project + # uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/go-release-build.yml b/.github/workflows/go-release-build.yml new file mode 100644 index 0000000..bc99dad --- /dev/null +++ b/.github/workflows/go-release-build.yml @@ -0,0 +1,45 @@ +name: build + +on: + push: + branches: + - 'master' + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - + name: Set up Go + uses: actions/setup-go@v2 + with: + go-version: 1.15 + + - + name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - + name: Tests + run: | + export GOPATH=/home/runner/go + mkdir -p $GOPATH/src/github.com/$GITHUB_ACTOR + mv $GITHUB_WORKSPACE $GOPATH/src/github.com/$GITHUB_ACTOR + ln -s $GOPATH/src/github.com/$GITHUB_REPOSITORY $GITHUB_WORKSPACE + # go mod tidy + go get -v ./... + go test -v ./... + + - + name: Run GoReleaser + uses: goreleaser/goreleaser-action@v2 + if: success() && startsWith(github.ref, 'refs/tags/') + with: + version: latest + args: release --rm-dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..8472cea --- /dev/null +++ b/.goreleaser.yml @@ -0,0 +1,31 @@ +project_name: cascadia + +archives: + - format: tar.gz + wrap_in_directory: true + format_overrides: + - goos: windows + format: zip + # remove README and LICENSE + files: + - none* + +builds: + - env: [CGO_ENABLED=0] + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm64 + +nfpms: +- maintainer: Tong Sun + description: CSS selector CLI tool + homepage: https://github.com/suntong/cascadia + license: MIT + formats: + - deb + - rpm + - apk diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index fbfa16b..0000000 --- a/.travis.yml +++ /dev/null @@ -1,51 +0,0 @@ -# -*- yaml -*- - -language: go - -env: - global: - # Package setup (Ref: http://pkg-go.alioth.debian.org/packaging.html) - - VERSION="${TRAVIS_TAG:=0.0~git$(date +%Y%m%d)-1}" - - PKG_URL="https://github.com/suntong/cascadia" - - PKG_CAT=utils - - PKG_ARCH=amd64 - - PKG_DESC="Go cascadia package command line CSS selector" - - PKG_VEND="suntong" - - PKG_MAINT='Tong Sun ' - - PKG_LICNS="MIT" - # Build time setup - - TZ=America/Toronto - - DATE_BUILD=`date -I` - -script: - - date - - go get -t -v ./... - - go build -v -ldflags="-X main.date=$DATE_BUILD" - - cascadia - - go test -v ./... - - - go get github.com/mitchellh/gox - - gox -ldflags="-X main.date=$DATE_BUILD" -osarch="linux/386 linux/amd64 darwin/amd64 windows/amd64" -output="out/{{.Dir}}-{{.OS}}-{{.Arch}}" -# linux/386 linux/amd64 linux/arm darwin/amd64 darwin/386 windows/amd64 windows/386 -# e.g.: out/cascadia-linux-amd64 - -before_deploy: - - gem install fpm --no-document - - make pkg - - sed -i -e "s/\$VERSION/$VERSION/" bintray-pkg.json - - sed -i -e "s/\$DATE/$DATE_BUILD/" bintray-pkg.json - -deploy: - - provider: bintray - user: suntong - key: ${BINTRAY_API_KEY} - file: bintray-bin.json - skip_cleanup: true - - - provider: bintray - user: suntong - key: $BINTRAY_API_KEY - file: bintray-pkg.json - skip_cleanup: true - on: -# tags: true diff --git a/bintray-bin.json b/bintray-bin.json deleted file mode 100644 index a9853b6..0000000 --- a/bintray-bin.json +++ /dev/null @@ -1,27 +0,0 @@ -{ - "package": { - "name": "cascadia", - "repo": "bin", - "subject": "suntong", - "desc": "Go cascadia package command line CSS selector", - "website_url": "https://github.com/suntong/cascadia", - "issue_tracker_url": "https://github.com/suntong/cascadia/issues", - "vcs_url": "https://github.com/suntong/cascadia.git", - "licenses": ["MIT"], - "public_download_numbers": false - }, - - "version": { - "name": "latest", - "gpgSign": false - }, - - "files": [{ - "includePattern": "out/(.*)", "uploadPattern": "cascadia/$1", - "matrixParams": { - "override": 1 - } - }], - - "publish": true -} diff --git a/bintray-pkg.json b/bintray-pkg.json deleted file mode 100644 index 86941df..0000000 --- a/bintray-pkg.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "package": { - "name": "cascadia", - "repo": "deb", - "subject": "suntong", - "desc": "Go cascadia package command line CSS selector", - "website_url": "https://github.com/suntong/cascadia", - "issue_tracker_url": "https://github.com/suntong/cascadia/issues", - "vcs_url": "https://github.com/suntong/cascadia.git", - "licenses": ["MIT"], - "public_download_numbers": false - }, - - "version": { - "name": "$VERSION", - "desc": "Release $VERSION", - "released": "$DATE", - "vcs_tag": "$VERSION", - "gpgSign": true - }, - - "files": [{ - "includePattern": "pkg/(.*)\\.deb", - "uploadPattern": "pool/main/c/$1_$VERSION_amd64.deb", - "matrixParams": { - "deb_distribution": "all", - "deb_component": "main", - "deb_architecture": "amd64", - "override": 1 - } - }], - - "publish": true -}