-
Notifications
You must be signed in to change notification settings - Fork 0
126 lines (106 loc) · 3.76 KB
/
build_main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
name: Main - 🚀 build package
on:
push:
branches:
- main
jobs:
version:
name: Version & Build
runs-on: macos-latest
environment: release
permissions:
contents: write
outputs:
version: ${{ steps.get_new_version.outputs.result}}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{secrets.ELEVATED_TOKEN}}
- name: 📇 Configure git
run: |
git fetch --prune --unshallow
git config --global user.name "GitHub Actions"
git config --global user.email "gh-actions@merckgroup.com"
shell: bash
# Retrieve the new version
- name: 🔂 Run standard-version
uses: actions/github-script@v7
with:
script: |
const {execSync} = require('child_process');
execSync('npx standard-version --skip.tag', {stdio: 'inherit'});
# Retrieve the new version
- name: ⏎ Get new version
uses: actions/github-script@v7
id: get_new_version
with:
result-encoding: string
script: |
const fs = require('fs');
const package = JSON.parse(fs.readFileSync('package.json', 'utf8'));
return package.version;
- name: Print new version
run: echo ${{ steps.get_new_version.outputs.result}}
# Bump the pubspec.yaml file
- name: ⬆️ Bump pubspec.yaml
uses: emdgroup/mtrust-urp/.github/actions/update-pubspec@main
with:
version: ${{ steps.get_new_version.outputs.result }}
directory: .
- name: 📝 Update version in readme
uses: emdgroup/mtrust-urp/.github/actions/update-pubspec-readme-version@main
with:
directory: .
- name: Setup Dart
uses: dart-lang/setup-dart@v1
- name: Prepare Flutter
uses: emdgroup/mtrust-urp/.github/actions/prepare-flutter@main
with:
directory: "."
- name: Validate Flutter
uses: emdgroup/mtrust-urp/.github/actions/validate-flutter@main
with:
directory: "."
is_package: true
- name: Check licenses
uses: emdgroup/mtrust-urp/.github/actions/check-dart-licenses@main
with:
directory: "."
# We first commit with proper message and add an empty commit to keep the files history clean
- name: Update repo versions
run: |
git add .
git commit -m "chore(release): ${{ steps.get_new_version.outputs.result }}"
git commit --allow-empty -m "chore(release): ${{ steps.get_new_version.outputs.result }} [skip ci]"
git push origin main
# For this part it is important to not push a commit with [skip ci] before the tag release
- name: Push tag for pub.dev
run: |
git commit --allow-empty -m "chore(release): ${{ steps.get_new_version.outputs.result }}"
git tag -a v${{ steps.get_new_version.outputs.result }} -m "Pub.dev version ${{ steps.get_new_version.outputs.result }}"
git push origin v${{ steps.get_new_version.outputs.result }}
rebase_dev:
name: Write changes to dev branch
needs: [version]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{secrets.ELEVATED_TOKEN}}
- name: Setup Git User
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "gh-actions@merckgroup.com"
- name: Update Test Branch
run: |
git checkout main
git fetch origin
git checkout dev
git pull
git merge origin/main
git push origin dev