Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 278fd29

Browse files
authored
Merge pull request #95 from comigor/beta-actions
Separate actions for push/pull_request and include beta branch checks
2 parents 2df1848 + e3eb627 commit 278fd29

5 files changed

Lines changed: 99 additions & 14 deletions

File tree

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
on: pull_request
2+
3+
name: CI
4+
5+
jobs:
6+
test:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Clone repository
10+
uses: actions/checkout@master
11+
- name: Run tests
12+
uses: comigor/actions/dart-test@master
13+
env:
14+
DTA_EXCLUDE_REGEX: example
15+
check-version-and-changelog:
16+
needs: test
17+
runs-on: ubuntu-latest
18+
container: golang
19+
steps:
20+
- uses: actions/checkout@master
21+
- run: |
22+
GO111MODULE=on go get -u github.com/itchyny/gojq/cmd/gojq@d24ecb5d89a9eee8b4cd2071bdff7585a8b44f0e
23+
cd "$GITHUB_WORKSPACE"
24+
- name: Check if version on pubspec.yaml was changed and if there's an entry for this new version on CHANGELOG
25+
run: |
26+
echo "GITHUB EVENT NAME: ${{ github.event_name }}"
27+
echo "GITHUB REF: $GITHUB_REF"
28+
echo "GITHUB REF: ${{ github.ref }}"
29+
echo "GITHUB HEAD REF: ${{ github.head_ref }}"
30+
echo "GITHUB BASE REF: ${{ github.base_ref }}"
31+
32+
git fetch --prune --unshallow
33+
where="origin/${{ github.base_ref }}"
34+
35+
diff=$(git diff $where pubspec.yaml)
36+
echo "$diff" | grep -E '\+.*version' || {
37+
echo "Version not bumped on pubspec"
38+
exit 1
39+
}
40+
41+
package_version=$(cat pubspec.yaml | gojq --yaml-input -r '.version')
42+
43+
# If are on master or beta
44+
if [ "${{ github.base_ref }}" = "master" ]; then
45+
echo "$package_version" | grep beta && {
46+
echo "Version cant contain beta"
47+
exit 1
48+
}
49+
elif [ "${{ github.base_ref }}" = "beta" ]; then
50+
echo "$package_version" | grep beta || {
51+
echo "Missing beta on version"
52+
exit 1
53+
}
54+
fi
55+
56+
cat CHANGELOG.md | grep "$package_version"
Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
on: [push, pull_request]
1+
on:
2+
push:
3+
branches:
4+
- master
5+
- beta
26

37
name: CI
48

59
jobs:
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
@@ -15,6 +20,7 @@ jobs:
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:
@@ -43,7 +69,7 @@ jobs:
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
@@ -52,7 +78,6 @@ jobs:
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

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# CHANGELOG
22

3+
## 5.0.4
4+
- Update CI to include beta branch.
5+
36
## 5.0.3
47
- Update examples to match latest changes.
58

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
[![Pub Package](https://img.shields.io/pub/v/artemis.svg)](https://pub.dev/packages/artemis)
1010
[![GitHub Actions](https://github.com/comigor/artemis/workflows/test/badge.svg)](https://github.com/comigor/artemis/actions)
1111

12+
Check the [**beta**](https://github.com/comigor/artemis/tree/beta) branch for the bleeding edge (and breaking) stuff.
13+
1214
Artemis is a code generator that looks for `schema.graphql` (GraphQL SDL - Schema Definition Language) and `*.graphql` files and builds `.dart` files typing that query, based on the schema. That's similar to what [Apollo](https://github.com/apollographql/apollo-client) does (Artemis is his sister anyway).
1315

1416
---

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: artemis
2-
version: 5.0.3
2+
version: 5.0.4
33

44
authors:
55
- Igor Borges <igor@borges.dev>

0 commit comments

Comments
 (0)