-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into add-quality-cache
- Loading branch information
Showing
8 changed files
with
311 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
name: Build packages | ||
# Big chunk of the build process logic is in the mage build targets | ||
on: | ||
workflow_call: | ||
push: | ||
branches: [master] | ||
tags: | ||
|
||
# Mage's `GenerateEnvFile` talks to GH API to setup tags, versions, etc. | ||
env: | ||
GITHUB_OWNER: mysteriumnetwork | ||
GITHUB_REPO: node | ||
GITHUB_SNAPSHOT_REPO: node-builds | ||
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
jobs: | ||
build-packages: | ||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
max-parallel: 4 | ||
matrix: | ||
platform: | ||
- PackageLinuxRaspberryImage | ||
- PackageLinuxAmd64 | ||
- PackageLinuxArm | ||
- PackageLinuxDebianAmd64 | ||
- PackageLinuxDebianArm64 | ||
- PackageLinuxDebianArm | ||
- PackageMacOSAmd64 | ||
- PackageMacOSArm64 | ||
- PackageWindowsAmd64 | ||
- PackageAndroid | ||
- PackageAndroidProvider | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.x' | ||
- name: Generate Env | ||
run: go run mage.go -v GenerateEnvFile | ||
|
||
- name: Setup FPM | ||
run: | | ||
sudo apt-get install ruby-dev build-essential | ||
sudo gem i fpm -f | ||
- name: Build package | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
run: | | ||
source build/env.sh | ||
# Following line ensures that s3 bucket name won't overlap with the old CI's target | ||
# Should be removed when the old CI is disabled | ||
export BUILD_NUMBER=$BUILD_NUMBER"-ghactions" | ||
go run mage.go -v ${{ matrix.platform }} | ||
build-swagger: | ||
runs-on: ubuntu-latest | ||
needs: [build-packages] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.x' | ||
- name: Generate Env | ||
run: go run mage.go -v GenerateEnvFile | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build docker | ||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
run: | | ||
source build/env.sh | ||
# Following line ensures that s3 bucket name won't overlap with the old CI's target | ||
# Should be removed when the old CI is disabled | ||
export BUILD_NUMBER=$BUILD_NUMBER"-ghactions" | ||
go run mage.go -v PackageDockerSwaggerRedoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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 }} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
name: Tests | ||
on: | ||
pull_request: | ||
|
||
env: | ||
GOFLAGS: "-count=1" | ||
|
||
jobs: | ||
unit-tests: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.x' | ||
|
||
- name: Install protoc | ||
run: sudo apt install -y protobuf-compiler | ||
|
||
- name: Unit tests and linters | ||
run: | | ||
go run mage.go -v Generate | ||
go run mage.go -v Check | ||
go run mage.go -v TestWithCoverage | ||
- name: Upload codecov report | ||
uses: codecov/codecov-action@v4 | ||
with: | ||
file: ./coverage.txt | ||
token: ${{ secrets.CODECOV_TOKEN }} | ||
|
||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
needs: unit-tests | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21.x' | ||
|
||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
|
||
- name: E2E basic test | ||
run: go run mage.go -v TestE2EBasic | ||
|
||
- name: E2E NAT test | ||
run: go run mage.go -v TestE2ENAT | ||
|
||
verify-build: | ||
needs: [unit-tests, e2e-tests] | ||
uses: ./.github/workflows/build-packages.yml | ||
secrets: inherit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.