Skip to content

Commit

Permalink
Automate release
Browse files Browse the repository at this point in the history
Signed-off-by: BugDiver <vinaysh@thoughtworks.com>
  • Loading branch information
BugDiver committed Jun 3, 2020
1 parent 0cf4e6c commit 53de40f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 32 deletions.
31 changes: 19 additions & 12 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
name: build
on: [push, pull_request]
on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:
name: UTs ${{ matrix.os }}
Expand All @@ -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
30 changes: 10 additions & 20 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 }}'

50 changes: 50 additions & 0 deletions .github/workflows/version.yml
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 53de40f

Please sign in to comment.