1- on : [push, pull_request]
1+ on :
2+ push :
3+ branches :
4+ - master
5+ - beta
26
37name : CI
48
59jobs :
610 test :
711 runs-on : ubuntu-latest
12+ if : github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta'
813 steps :
914 - name : Clone repository
1015 uses : actions/checkout@master
1520 check-version-and-changelog :
1621 needs : test
1722 runs-on : ubuntu-latest
23+ if : github.ref == 'refs/heads/master' || github.ref == 'refs/heads/beta'
1824 container : golang
1925 steps :
2026 - uses : actions/checkout@master
@@ -23,18 +29,38 @@ jobs:
2329 cd "$GITHUB_WORKSPACE"
2430 - name : Check if version on pubspec.yaml was changed and if there's an entry for this new version on CHANGELOG
2531 run : |
32+ echo "GITHUB EVENT NAME: ${{ github.event_name }}"
33+ echo "GITHUB REF: $GITHUB_REF"
34+ echo "GITHUB REF: ${{ github.ref }}"
35+ echo "GITHUB HEAD REF: ${{ github.head_ref }}"
36+ echo "GITHUB BASE REF: ${{ github.base_ref }}"
37+
2638 git fetch --prune --unshallow
27- if test "${{ github.ref }}" = "refs/heads/master"; then
28- where=HEAD~$(gojq '.commits | length' "${GITHUB_EVENT_PATH}")
29- else
30- where=origin/master
31- fi
39+ where=HEAD~$(gojq '.commits | length' "${GITHUB_EVENT_PATH}")
40+
3241 diff=$(git diff $where pubspec.yaml)
33- echo "$diff" | grep -E '\+.*version'
34- mkdir -p artifacts
35- git diff -U0 $where CHANGELOG.md | grep '^\+' | grep -Ev '^(--- a/|\+\+\+ b/)' | sed -E 's/^\+(.*)/\1/g' > artifacts/changelog
42+ echo "$diff" | grep -E '\+.*version' || {
43+ echo "Version not bumped on pubspec"
44+ exit 1
45+ }
46+
3647 package_version=$(cat pubspec.yaml | gojq --yaml-input -r '.version')
48+
49+ # If are on master or beta
50+ if [ "${{ github.ref }}" = "refs/heads/master" ]; then
51+ echo "$package_version" | grep beta && {
52+ echo "Version cant contain beta"
53+ exit 1
54+ }
55+ elif [ "${{ github.ref }}" = "refs/heads/beta" ]; then
56+ echo "$package_version" | grep beta || {
57+ echo "Missing beta on version"
58+ exit 1
59+ }
60+ fi
61+
3762 cat CHANGELOG.md | grep "$package_version"
63+ mkdir -p artifacts
3864 echo "$package_version" > artifacts/version
3965 - uses : actions/upload-artifact@v1
4066 with :
4369 create-tag-and-release :
4470 needs : check-version-and-changelog
4571 runs-on : ubuntu-latest
46- if : contains( github.ref, ' master')
72+ if : github.ref == 'refs/heads/ master' || github.ref == 'refs/heads/beta'
4773 steps :
4874 - uses : actions/checkout@master
4975 - uses : actions/download-artifact@v1
5278 - id : vars
5379 run : |
5480 echo "::set-output name=package_version::v$(cat package_data/version)"
55- echo "::set-output name=changelog::$(cat package_data/changelog)"
5681 - name : Push tag
5782 uses : anothrNick/github-tag-action@master
5883 env :
@@ -65,11 +90,10 @@ jobs:
6590 with :
6691 tag_name : ${{ steps.vars.outputs.package_version }}
6792 release_name : Release ${{ steps.vars.outputs.package_version }}
68- body : ${{ steps.vars.outputs.changelog }}
6993 deploy :
7094 needs : create-tag-and-release
7195 runs-on : ubuntu-latest
72- if : contains( github.ref, ' master')
96+ if : github.ref == 'refs/heads/ master' || github.ref == 'refs/heads/beta'
7397 steps :
7498 - uses : actions/checkout@master
7599 - name : Publish to pub.dev
0 commit comments