Skip to content

Commit

Permalink
Merge pull request #68 from testfairy/feat-publish-ci
Browse files Browse the repository at this point in the history
Added publishing CI
  • Loading branch information
diegoperini authored Dec 20, 2021
2 parents 5b7e095 + 064de37 commit 914ce89
Show file tree
Hide file tree
Showing 10 changed files with 157 additions and 65 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Build

on: [push]

jobs:
build:
timeout-minutes: 45

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Build and test
run: |
export TF_API_KEY=${{ secrets.TF_API_KEY }}
./gradlew uploadArchives
cd example/TestApplication
./gradlew testfairyDebug
shell: bash
91 changes: 91 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Publish plugin to testfairy-maven repo as a PR

on:
push:
tags:
- '*'

jobs:
publish:
runs-on: ubuntu-latest

strategy:
fail-fast: true

steps:
- uses: actions/checkout@v1

- name: Setup java
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Setup Android SDK
uses: android-actions/setup-android@v2

- name: Setup Github CLI and login
run: |
sudo apt install -y gh
echo ${{ secrets.MAVEN_GH_SSH_KEY_BASE64 }} | base64 --decode > ghkey
# sudo chmod 600 ghkey
# eval `ssh-agent -s`
# ssh-add ghkey
echo ${{ secrets.MAVEN_GH_TOKEN }} > maven-token
gh auth login --with-token < maven-token
export MAVEN_GH_SSH_KEY=`cat ghkey`
shell: bash

- name: Check out testfairy-maven
uses: actions/checkout@v2
with:
repository: testfairy/testfairy-maven
token: ${{ secrets.MAVEN_GH_TOKEN }}
ssh-key: ${{ env.MAVEN_GH_SSH_KEY }}
path: './testfairy-maven'

- name: Build
run: |
export TF_API_KEY=${{ secrets.TF_API_KEY }}
echo "TF_GRADLE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
export TF_GRADLE_VERSION=${GITHUB_REF#refs/*/}
./gradlew uploadArchives
shell: bash

- name: Upload release artifacts
uses: softprops/action-gh-release@v1
with:
name: Version ${{ env.TF_GRADLE_VERSION }}
tag_name: ${{ env.TF_GRADLE_VERSION }}
fail_on_unmatched_files: true
prerelease: false
files: |
testfairy-maven/com/testfairy/plugins/gradle/testfairy/${{ env.TF_GRADLE_VERSION }}/testfairy-${{ env.TF_GRADLE_VERSION }}.jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to testfairy-maven
run: |
if [ "$TF_GRADLE_VERSION" == "HEAD" ]; then
echo "Cannot publish HEAD. Please use proper semver in your release."
exit 1
fi
git config --global user.email "[email protected]"
git config --global user.name "testfairy-maven-publish"
cd testfairy-maven
GIT_BRANCH="publish-gradle-$TF_GRADLE_VERSION"
git branch $GIT_BRANCH
git checkout $GIT_BRANCH
git add *
git commit -m "Publishing TestFairy Gradle Plugin $TF_GRADLE_VERSION"
git push -u origin $GIT_BRANCH
gh pr create --title "Publishing TestFairy Gradle Plugin $TF_GRADLE_VERSION" --body "$TF_GRADLE_VERSION"
shell: bash

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ composer.lock
/build
/captures
.externalNativeBuild
repo/com
26 changes: 0 additions & 26 deletions .travis.yml

This file was deleted.

12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,21 @@ Changelog
Development
----

* Install Groovy SDK.
* Install IntelliJ IDEA.
* Install Groovy SDK if IntelliJ fails importing groovy dependencies. (only affects static analysis)
* Open project and setup latest Groovy SDK and Java SDK (1.8) path.
* Sync.

To test the plugin after code change, run:

```bash
export TF_API_KEY=${{ secrets.TF_API_KEY }}

./gradlew uploadArchives
cd example/TestApplication
./gradlew testfairyDebug
```

Bugs
----

Expand Down
30 changes: 21 additions & 9 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
apply plugin: 'groovy'

dependencies {
compile gradleApi()
compile localGroovy()
compile 'commons-io:commons-io:2.4'
compile 'org.apache.httpcomponents:httpmime:4.2.5'
compile 'org.apache.commons:commons-compress:1.9'
compile 'com.android.tools.build:gradle:3.4.0'
implementation gradleApi()
implementation localGroovy()
implementation 'commons-io:commons-io:2.11.0'
implementation 'org.apache.httpcomponents:httpmime:4.5.13'
implementation 'org.apache.commons:commons-compress:1.21'
implementation 'com.android.tools.build:gradle:3.4.3'
}

apply plugin: 'maven'

group = 'com.testfairy.plugins.gradle'
version = '3.5'

def pluginVersion = System.getenv('TF_GRADLE_VERSION')
version = (pluginVersion != null && pluginVersion.length() > 0) ? pluginVersion : "HEAD"

System.out.println("TestFairy Gradle Plugin Version: " + project.version);

repositories {
mavenCentral()
Expand All @@ -28,11 +32,19 @@ compileJava {
targetCompatibility = 1.6
}



uploadArchives {
repositories {
mavenDeployer {
// repository(url: uri('repo'))
repository(url: uri('../testfairy-maven'))
def pluginVersion2 = System.getenv('TF_GRADLE_VERSION')
def version2 = (pluginVersion2 != null && pluginVersion2.length() > 0) ? pluginVersion2 : "HEAD"
def repoUrl = version2.equals("HEAD") ? uri('./repo') : uri('./testfairy-maven')

System.out.println("Version: " + version2)
System.out.println("Repo: " + repoUrl)

repository(url: repoUrl)

pom.project {
name 'TestFairy Uploader Plugin for Gradle'
Expand Down
9 changes: 6 additions & 3 deletions example/TestApplication/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,22 @@ buildscript {
google()

//Enable when testing local plugin
maven { url '../../../../testfairy-maven' }
maven { url ('../../../repo') }
maven { url ('../../../testfairy-maven') }
maven { url ('../../../../repo') }
maven { url ('../../../../testfairy-maven') }

//Enable when testing remote release
// maven { url 'https://www.testfairy.com/maven' }
}

dependencies {
classpath 'com.testfairy.plugins.gradle:testfairy:3.+'
classpath 'com.testfairy.plugins.gradle:testfairy:+'
}
}

testfairyConfig {
apiKey "ae6edb30a71f825093216f851a9bf414984cb131"
apiKey System.getenv('TF_API_KEY')
testersGroups "myself"
notify true
video "wifi"
Expand Down

This file was deleted.

Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
Empty file added repo/.keep
Empty file.

0 comments on commit 914ce89

Please sign in to comment.