diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 81c1de6..de83a91 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,5 +1,12 @@ name: build -on: [push, pull_request] +on: + push: + branches: + - master + pull_request: + branches: + - master + jobs: build: name: UTs ${{ matrix.os }} @@ -8,16 +15,16 @@ jobs: matrix: os: [windows-latest, ubuntu-latest, macos-latest] steps: - - name: Set up Go 1.13 - uses: actions/setup-go@v1 - with: - go-version: 1.13 - id: go + - name: Set up Go 1.13 + uses: actions/setup-go@v1 + with: + go-version: 1.13 + id: go - - name: Check out code into the Go module directory - uses: actions/checkout@v1 + - name: Check out code into the Go module directory + uses: actions/checkout@v1 - - name: Build - run: | - go run build/make.go - go run build/make.go --install + - name: Build + run: | + go run build/make.go + go run build/make.go --install diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 156b9bd..0f5da6c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,15 +1,20 @@ name: deploy -on: [deployment] +on: + pull_request: + types: + - closed jobs: deploy: - name: deploy flash - runs-on: macos-latest + if: github.event_name == 'pull_request' && github.event.action == 'closed' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'ReleaseCandidate') + name: Deploy flash + runs-on: ubuntu-latest env: GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}' steps: - uses: actions/checkout@v1 + - uses: geertvdc/setup-hub@master - name: Setup go 1.13.1 uses: actions/setup-go@v1 @@ -20,9 +25,8 @@ jobs: run: | go run build/make.go --all-platforms go run build/make.go --all-platforms --distro - - name: Install hub - run: brew install hub - - name: update + + - name: Create release and deploy assets run: | cd deploy if [ -z "$version" ]; then @@ -50,17 +54,3 @@ jobs: exit 1 fi done - - name: 'deployment success' - if: success() - uses: 'deliverybot/status@master' - with: - state: 'success' - token: '${{ secrets.GITHUB_TOKEN }}' - - - name: 'deployment failure' - if: failure() - uses: 'deliverybot/status@master' - with: - state: 'failure' - token: '${{ secrets.GITHUB_TOKEN }}' - diff --git a/.github/workflows/version.yml b/.github/workflows/version.yml new file mode 100644 index 0000000..4693c4c --- /dev/null +++ b/.github/workflows/version.yml @@ -0,0 +1,50 @@ +name: Version Check +on: + pull_request: + types: + - opened + - synchronize + +jobs: + check: + name: check if version is bumped + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + with: + python-version: '3.x' + + - name: Verify version is bumped or not + id: version_check + env: + tags_url: ${{ toJson(github.event.pull_request.base.repo.tags_url) }} + run: | + import json + import os + from distutils.version import StrictVersion + from urllib import request + + file_name = "plugin.json" + repo_name = os.environ["GITHUB_REPOSITORY"] + res = request.urlopen("https://api.github.com/repos/{}/tags".format(repo_name)) + data = res.read().decode("utf-8") + tags = json.loads(data) + latest_release_version = StrictVersion(tags[0]["name"].replace('v', '')) + + with open(file_name, 'r') as f: + data = json.load(f) + current_version = StrictVersion(data["version"]) + + print("::set-output name=is_version_bumped::{0}".format(current_version > latest_release_version)) + shell: python + + - uses: christianvuerings/add-labels@v1 + if: steps.version_check.outputs.is_version_bumped == 'True' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + labels: | + ReleaseCandidate