-
Notifications
You must be signed in to change notification settings - Fork 312
132 lines (111 loc) · 4.95 KB
/
mobile-release.yml
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
127
128
129
130
131
132
name: Mobile-release
on:
release:
types: [released]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: Get Release
run: |
echo $RELEASE_VERSION
echo ${{ env.RELEASE_VERSION }}
- name: Checkout tools repo
uses: actions/checkout@v4
with:
repository: mysteriumnetwork/mysterium-mobile-provider
ref: 'master'
path: mobile-app
token: ${{ secrets.REPO_TOKEN }}
- name: Update version
run: |
APP_VERSION=$(echo "$(grep "versionName" "./mobile-app/android/app/build.gradle.kts" | awk -F '"' '{print $2}')" + 0.1 | bc)
sed -i -E "/versionName\s*=\s*\"[0-9]+\.[0-9]+\"/s/\"[0-9]+\.[0-9]+\"/\"$APP_VERSION\"/" "./mobile-app/android/app/build.gradle.kts"
sed -i -E "/node\s*=\s*\"[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?\"/s/\"[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?\"/\"${{ env.RELEASE_VERSION }}\"/" "./mobile-app/android/gradle/libs.versions.toml"
- name: Pushes to another repository
id: push_directory
uses: cpina/github-action-push-to-another-repository@main
env:
API_TOKEN_GITHUB: ${{ secrets.REPO_TOKEN }}
with:
source-directory: mobile-app
destination-github-username: 'mysteriumnetwork'
destination-repository-name: 'mysterium-mobile-provider'
user-email: [email protected]
commit-message: Create release version ${{ env.RELEASE_VERSION }}
target-branch: master
- name: Send pull-request
env:
GH_TOKEN: ${{ secrets.REPO_TOKEN }}
run: |
LATEST_TAG=$(git describe --tags --always --abbrev=0)
REPOSITORY="mysteriumTeam/mysterium-mobile-provider"
FOLDER="bin/$REPOSITORY"
BRANCH_NAME="release-$LATEST_TAG"
# Clone the remote repository and change working directory to the
# folder it was cloned to.
git clone \
--depth=1 \
--branch=bitrise \
https://mpolubotko:${{ secrets.REPO_TOKEN }}@github.com/$REPOSITORY \
$FOLDER
cd $FOLDER
# Setup the committers identity.
git config user.email "[email protected]"
git config user.name "MysteriumTeam"
# Create a new feature branch for the changes.
git checkout -b $BRANCH_NAME
# Update the script files to the latest version.
cp -R ../../../mobile-app/android android
# Commit the changes and push the feature branch to origin
git add .
git commit -m "update files for new release version $LATEST_TAG"
git push origin $BRANCH_NAME
# Store the PAT in a file that can be accessed by the
# GitHub CLI.
echo "${{ secrets.REPO_TOKEN }}" > token.txt
# Authorize GitHub CLI for the current repository and
# create a pull-request containing the updates.
PR_URL=$(gh pr create \
--body "" \
--title "Release $LATEST_TAG" \
--head "$BRANCH_NAME" \
--base "master" \
| sed -n 's#https://github\.com/[^/]\+/[^/]\+/\pull/\([0-9]\+\).*#\1#p')
echo "PR_NUMBER=$PR_URL" >> $GITHUB_ENV
- name: Approve Pull Request
env:
GITHUB_TOKEN: ${{ secrets.REPO_TOKEN }}
REPO_OWNER: "MysteriumTeam"
REPO_NAME: "mysterium-mobile-provider"
PR_NUMBER: ${{ env.PR_NUMBER }}
run: |
response=$(curl -s -o /dev/null -w "%{http_code}" -L -X PUT \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/pulls/$PR_NUMBER/merge \
-d '{"commit_title":"Release v${{ env.RELEASE_VERSION }}","commit_message":"${{ env.RELEASE_VERSION }}"}')
# Check HTTP response
if [ "$response" == "204" ] || [ "$response" == "200" ] || [ "$response" == "201" ]; then
echo "PR was approved successfully"
else
echo "Couldn't approved PR, HTTP-status: $response"
exit 1
fi
- name: "Call Bitrise API"
uses: indiesdev/[email protected]
with:
url: https://api.bitrise.io/v0.1/apps/${{ secrets.BITRISE_APP_ID }}/builds
method: "POST"
id: api
accept: 200, 201
headers: '{ "accept": "application/json", "Authorization": "${{ secrets.BITRISE_TOKEN }}", "Content-Type": "application/json" }'
body: '{ "hook_info": {"type": "bitrise"}, "build_params": {"branch":"master", "workflow_id":"build"}}'
timeout: 10000
log-response: true
- name: "Bitrise response"
run: echo ${{ steps.api.outputs.response }}