• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Workflow to build release artifacts
2
3name: release artifacts
4
5on:
6  release:
7    types: [ created ]
8
9jobs:
10  build-and-test:
11
12    # The type of runner that the job will run on
13    runs-on: ubuntu-latest
14
15    steps:
16    - name: Setup Java 9
17      uses: actions/setup-java@v1.4.3
18      with:
19        java-version: '9'
20        java-package: jdk
21        architecture: x64
22    - name: set JDK_9 environment variable for kotlin compiler
23      env:
24        ACTIONS_ALLOW_UNSECURE_COMMANDS: true
25      run: echo ::set-env name=JDK_9::$(echo $JAVA_HOME)
26    - name: Setup Java 11
27      uses: actions/setup-java@v1.4.3
28      with:
29        java-version: '11'
30        java-package: jdk
31        architecture: x64
32
33    # Checkout
34    - uses: actions/checkout@v2
35
36    # Build cache
37    - name: Cache Gradle Cache
38      uses: actions/cache@v2
39      with:
40        path: ~/.gradle/caches
41        key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}-${{ hashFiles('**/gradle.properties') }}
42        # An ordered list of keys to use for restoring the cache if no cache hit occurred for key
43        restore-keys: |
44          ${{ runner.os }}-gradle-
45    - name: Cache gradle wrapper
46      uses: actions/cache@v2
47      with:
48        path: ~/.gradle/wrapper
49        key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
50
51    # Run tests
52    - name: test
53      shell: bash
54      run: ./gradlew --stacktrace --info test
55    - name: Upload test results
56      if: always()
57      uses: actions/upload-artifact@v3
58      with:
59        name: test-reports-${{ runner.os }}
60        path: |
61          compiler-plugin/build/reports
62          integration-tests/build/reports
63          gradle-plugin/build/reports
64          common-util/build/reports
65
66    # Build KSP artifacts
67    - name: build
68      run: |
69        REF=${{ github.ref }} # refs/tags/$KSP_VERSION
70        ./gradlew --info -PkspVersion=${REF:10} -PoutRepo=$(pwd)/build/repos/release publishAllPublicationsToMavenRepository
71    - name: pack
72      run: cd build/repos/release/ && zip -r ../../artifacts.zip .
73    - name: Upload Release Asset
74      uses: actions/upload-release-asset@v1
75      env:
76        GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77      with:
78        upload_url: ${{ github.event.release.upload_url }}
79        asset_path: ./build/artifacts.zip
80        asset_name: artifacts.zip
81        asset_content_type: application/zip
82