|
| 1 | +name: Maven CI |
| 2 | + |
| 3 | +on: |
| 4 | + create: |
| 5 | + tags: |
| 6 | + - 'v*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ${{ matrix.os }} |
| 11 | + |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 15 | + java: [13] |
| 16 | + |
| 17 | + env: |
| 18 | + WEBRTC_CACHE_BRANCH: 3987 |
| 19 | + WEBRTC_CHECKOUT_FOLDER: ${{ github.workspace }}/.work/webrtc |
| 20 | + WEBRTC_INSTALL_FOLDER: ${{ github.workspace }}/.work/webrtc/build |
| 21 | + |
| 22 | + steps: |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v2 |
| 25 | + |
| 26 | + - name: Set up Linux audio system # Required for testing |
| 27 | + if: runner.os == 'Linux' |
| 28 | + run: | |
| 29 | + sudo apt-get install -y pulseaudio |
| 30 | + pulseaudio --start |
| 31 | +
|
| 32 | + - name: Set up WebRTC cache |
| 33 | + uses: actions/cache@v1 |
| 34 | + with: |
| 35 | + path: ${{ env.WEBRTC_INSTALL_FOLDER }} |
| 36 | + key: webrtc-${{ env.WEBRTC_CACHE_BRANCH }}-${{ runner.os }}-${{ hashFiles('webrtc-jni/pom.xml') }} |
| 37 | + restore-keys: webrtc-${{ env.WEBRTC_CACHE_BRANCH }}-${{ runner.os }}- |
| 38 | + |
| 39 | + - name: Set up Maven cache |
| 40 | + uses: actions/cache@v1 |
| 41 | + with: |
| 42 | + path: ~/.m2/repository |
| 43 | + key: maven-${{ runner.os }}-${{ hashFiles('**/pom.xml') }} |
| 44 | + restore-keys: maven-${{ runner.os }}- |
| 45 | + |
| 46 | + - name: Set up JDK ${{ matrix.java }} |
| 47 | + uses: actions/setup-java@v1 |
| 48 | + with: |
| 49 | + java-version: ${{ matrix.java }} |
| 50 | + |
| 51 | + - name: Set up GPG |
| 52 | + env: |
| 53 | + GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }} |
| 54 | + run: echo -e "$GPG_PRIVATE_KEY" | gpg --import --batch |
| 55 | + shell: bash |
| 56 | + |
| 57 | + - name: Create Release |
| 58 | + if: runner.os == 'Linux' # Create release only once |
| 59 | + uses: actions/create-release@v1 |
| 60 | + env: |
| 61 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 62 | + with: |
| 63 | + tag_name: ${{ github.ref }} |
| 64 | + release_name: Release ${{ github.ref }} |
| 65 | + draft: false |
| 66 | + prerelease: false |
| 67 | + |
| 68 | + - name: Build |
| 69 | + run: mvn package -DskipTests -s .github/workflows/settings.xml |
| 70 | + |
| 71 | + - name: Test |
| 72 | + run: mvn -B jar:jar surefire:test |
| 73 | + |
| 74 | + - name: Deploy |
| 75 | + env: |
| 76 | + GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} |
| 77 | + NEXUS_USERNAME: ${{ secrets.MAVEN_USERNAME }} |
| 78 | + NEXUS_PASSWORD: ${{ secrets.MAVEN_PASSWORD }} |
| 79 | + run: mvn deploy -Prelease -DskipTests -s .github/workflows/settings.xml |
| 80 | + |
| 81 | + - name: Get demo bundle name |
| 82 | + id: get-bundle |
| 83 | + run: echo ::set-output name=bundle::$(basename webrtc-demo/webrtc-demo-javafx/target/webrtc-javafx-demo-*.jar) |
| 84 | + shell: bash |
| 85 | + |
| 86 | + - name: Get release context |
| 87 | + id: get-release-context |
| 88 | + run: | |
| 89 | + owner=${{ github.event.repository.owner.name }} |
| 90 | + api_url=https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest |
| 91 | + upload_url=$(curl -s -u $owner:${{ secrets.GITHUB_TOKEN }} $api_url | jq -r '.upload_url') |
| 92 | + echo ::set-output name=upload_url::$upload_url |
| 93 | + shell: bash |
| 94 | + |
| 95 | + - name: Upload demo release asset |
| 96 | + uses: actions/upload-release-asset@v1 |
| 97 | + env: |
| 98 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 99 | + with: |
| 100 | + upload_url: ${{ steps.get-release-context.outputs.upload_url }} |
| 101 | + asset_path: ./webrtc-demo/webrtc-demo-javafx/target/${{ steps.get-bundle.outputs.bundle }} |
| 102 | + asset_name: ${{ steps.get-bundle.outputs.bundle }} |
| 103 | + asset_content_type: application/java-archive |
0 commit comments