|
| 1 | +name: Java CI with Maven |
| 2 | + |
| 3 | +env: |
| 4 | + # find out this value by opening https://api.github.com/repos/<owner>/<repo>/releases |
| 5 | + # in your browser and copy the full "upload_url" value including the {?name,label} part |
| 6 | + UPLOAD_URL: https://uploads.github.com/repos/MarginallyClever/NodeGraphCore/releases/60280644/assets{?name,label} |
| 7 | + RELEASE_ID: 60280644 # same as above (id can just be taken out the upload_url, it's used to find old releases) |
| 8 | + |
| 9 | +on: |
| 10 | + push: |
| 11 | + branches: |
| 12 | + - master |
| 13 | + pull_request: |
| 14 | + |
| 15 | +jobs: |
| 16 | + build: |
| 17 | + runs-on: windows-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v2 |
| 20 | + |
| 21 | + - uses: actions/setup-java@v2 |
| 22 | + with: |
| 23 | + distribution: 'temurin' |
| 24 | + java-version: '17' |
| 25 | + cache: 'maven' |
| 26 | + |
| 27 | + # from https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven |
| 28 | + - name: Build and Test with Maven |
| 29 | + timeout-minutes: 15 |
| 30 | + run: ./mvnw -B test |
| 31 | + |
| 32 | + - name: Package with Maven |
| 33 | + run: ./mvnw -B clean package -DskipTests |
| 34 | + |
| 35 | + - name: Prepare universal package |
| 36 | + shell: bash |
| 37 | + run: | |
| 38 | + mkdir -p target/universal-package && |
| 39 | + cp src/main/package/avrdude.* src/main/package/firmware.hex src/main/package/*.bat src/main/package/start* src/main/package/thankyou.* target/universal-package/ && |
| 40 | + cp CONTRIBUTING.md LICENSE README.md target/universal-package/ && |
| 41 | + cp target/NodeGraphCore-*-with-dependencies.jar target/universal-package/ && |
| 42 | + cd target/universal-package/ && |
| 43 | + 7z a -tzip NodeGraphCore.zip . && |
| 44 | + mv NodeGraphCore.zip ../.. |
| 45 | +
|
| 46 | + - name: Deploy universal release |
| 47 | + if: github.repository == 'MarginallyClever/NodeGraphCore' && github.ref == 'refs/heads/master' |
| 48 | + uses: WebFreak001/[email protected] |
| 49 | + env: |
| 50 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # automatically provided by github actions |
| 51 | + with: |
| 52 | + upload_url: ${{ env.UPLOAD_URL }} |
| 53 | + release_id: ${{ env.RELEASE_ID }}{ |
| 54 | + asset_path: NodeGraphCore.zip # path to archive to upload |
| 55 | + asset_name: NodeGraphCore-nightly-$$.zip # name to upload the release as, use $$ to insert date (YYYYMMDD) and 6 letter commit hash |
| 56 | + asset_content_type: application/zip # required by GitHub API |
| 57 | + max_releases: 1 # optional, if there are more releases than this matching the asset_name, the oldest ones are going to be deleted |
| 58 | + |
| 59 | + - name: Upload artifact for package |
| 60 | + uses: actions/upload-artifact@v2 |
| 61 | + with: |
| 62 | + name: jar |
| 63 | + retention-days: 1 |
| 64 | + path: | |
| 65 | + src/main/package/jpackage* |
| 66 | + src/main/package/logo* |
| 67 | + LICENSE |
| 68 | + target/package/* |
| 69 | +
|
| 70 | + package: |
| 71 | + needs: build |
| 72 | + runs-on: ${{ matrix.os }} |
| 73 | + strategy: |
| 74 | + matrix: |
| 75 | + os: [macos-latest, ubuntu-latest, windows-latest] |
| 76 | + steps: |
| 77 | + - uses: actions/setup-java@v2 |
| 78 | + with: |
| 79 | + distribution: 'temurin' |
| 80 | + java-version: '17' |
| 81 | + |
| 82 | + - uses: actions/download-artifact@v2 |
| 83 | + with: |
| 84 | + name: jar |
| 85 | + |
| 86 | + - name: Upload artifact for testing purpose |
| 87 | +# if: github.repository == 'MarginallyClever/NodeGraphCore' || github.ref != 'refs/heads/master' |
| 88 | + uses: actions/upload-artifact@v2 |
| 89 | + with: |
| 90 | + name: ${{ env.BINARY }} |
| 91 | + retention-days: 2 |
| 92 | + path: ${{ env.BINARY }} |
0 commit comments