|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ master ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + check_code: # Validates the code (see checkBuild.yml) |
| 9 | + runs-on: ubuntu-latest |
| 10 | + steps: |
| 11 | + - uses: actions/checkout@v2 |
| 12 | + |
| 13 | + - name: Set up JDK 8 |
| 14 | + uses: actions/setup-java@v2 |
| 15 | + with: |
| 16 | + distribution: 'zulu' |
| 17 | + java-version: '8' |
| 18 | + java-package: jdk+fx |
| 19 | + cache: 'maven' |
| 20 | + |
| 21 | + - name: Build with Maven |
| 22 | + run: mvn -B clean verify -Pjava8 |
| 23 | + |
| 24 | + - name: Check for uncommited changes |
| 25 | + run: | |
| 26 | + if [[ "$(git status --porcelain)" != "" ]]; then |
| 27 | + echo ---------------------------------------- |
| 28 | + echo git status |
| 29 | + echo ---------------------------------------- |
| 30 | + git status |
| 31 | + echo ---------------------------------------- |
| 32 | + echo git diff |
| 33 | + echo ---------------------------------------- |
| 34 | + git diff |
| 35 | + echo ---------------------------------------- |
| 36 | + echo Troubleshooting |
| 37 | + echo ---------------------------------------- |
| 38 | + echo "::error::Unstaged changes detected. Locally try running: git clean -ffdx && mvn -B clean verify" |
| 39 | + exit 1 |
| 40 | + fi |
| 41 | +
|
| 42 | + prepare_release: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + needs: [check_code] |
| 45 | + outputs: |
| 46 | + upload_url: ${{ steps.create_draft.outputs.upload_url }} |
| 47 | + steps: |
| 48 | + - uses: actions/checkout@v2 |
| 49 | + |
| 50 | + - name: Configure Git |
| 51 | + run: | |
| 52 | + git config --global user.email "actions@github.com" |
| 53 | + git config --global user.name "GitHub Actions" |
| 54 | + |
| 55 | + - name: Un-SNAP |
| 56 | + run: mvn -B versions:set -DremoveSnapshot -DgenerateBackupPoms=false |
| 57 | + |
| 58 | + - name: Get version |
| 59 | + id: version |
| 60 | + # Ignores the suffix |
| 61 | + run: | |
| 62 | + read_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 63 | + parts=(${read_version//-/ }) |
| 64 | + echo "::set-output name=release::${parts[0]}" |
| 65 | + |
| 66 | + - name: Commit and Push |
| 67 | + run: | |
| 68 | + git add -A |
| 69 | + git commit -m "Release ${{ steps.version.outputs.release }}" |
| 70 | + git push origin |
| 71 | + git tag v${{ steps.version.outputs.release }} |
| 72 | + git push origin --tags |
| 73 | + |
| 74 | + - name: Create Release |
| 75 | + id: create_release |
| 76 | + uses: actions/create-release@v1 |
| 77 | + env: |
| 78 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 79 | + with: |
| 80 | + tag_name: v${{ steps.version.outputs.release }} |
| 81 | + release_name: v${{ steps.version.outputs.release }} |
| 82 | + commitish: master |
| 83 | + body: | |
| 84 | + ## Installation [](https://mvnrepository.com/artifact/com.xdev-software/xapi-fx) |
| 85 | + Add the following lines to your pom: |
| 86 | + ```XML |
| 87 | + <dependency> |
| 88 | + <groupId>com.xdev-software</groupId> |
| 89 | + <artifactId>xapi-fx</artifactId> |
| 90 | + <version>${{ steps.version.outputs.release }}-java<JavaVersion></version> |
| 91 | + </dependency> |
| 92 | + ``` |
| 93 | + draft: false |
| 94 | + prerelease: false |
| 95 | + |
| 96 | + publish_central: # Publish the code to central |
| 97 | + runs-on: ubuntu-latest |
| 98 | + needs: [prepare_release] |
| 99 | + strategy: |
| 100 | + matrix: |
| 101 | + java: [11, 17] |
| 102 | + java-package: [jdk] |
| 103 | + distribution: [temurin] |
| 104 | + include: |
| 105 | + # When building Java 8 we need JavaFX on JDK basis |
| 106 | + - java: 8 |
| 107 | + java-package: jdk+fx |
| 108 | + distribution: zulu |
| 109 | + steps: |
| 110 | + - uses: actions/checkout@v2 |
| 111 | + |
| 112 | + - name: Init Git and pull |
| 113 | + run: | |
| 114 | + git config --global user.email "actions@github.com" |
| 115 | + git config --global user.name "GitHub Actions" |
| 116 | + git pull |
| 117 | + |
| 118 | + - name: Set up JDK and configure for ossrh |
| 119 | + uses: actions/setup-java@v2 |
| 120 | + with: # running setup-java again overwrites the settings.xml |
| 121 | + distribution: ${{ matrix.distribution }} |
| 122 | + java-version: ${{ matrix.java }} |
| 123 | + java-package: ${{ matrix.java-package }} |
| 124 | + server-id: ossrh |
| 125 | + server-username: MAVEN_CENTRAL_USERNAME |
| 126 | + server-password: MAVEN_CENTRAL_TOKEN |
| 127 | + gpg-passphrase: MAVEN_GPG_PASSPHRASE |
| 128 | + gpg-private-key: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }} |
| 129 | + |
| 130 | + - name: Publish to Apache Maven Central |
| 131 | + run: mvn -B deploy -Possrh,java${{ matrix.java }} |
| 132 | + env: |
| 133 | + MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }} |
| 134 | + MAVEN_CENTRAL_TOKEN: ${{ secrets.MAVEN_CENTRAL_TOKEN }} |
| 135 | + MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }} |
| 136 | + |
| 137 | + publish-pages: |
| 138 | + # Java 8-variant has no dependencies |
| 139 | + name: Publish dependencies and licenses to github pages (Java 11) |
| 140 | + runs-on: ubuntu-latest |
| 141 | + needs: [prepare_release] |
| 142 | + steps: |
| 143 | + - uses: actions/checkout@v2 |
| 144 | + |
| 145 | + - name: Init Git and pull |
| 146 | + run: | |
| 147 | + git config --global user.email "actions@github.com" |
| 148 | + git config --global user.name "GitHub Actions" |
| 149 | + git pull |
| 150 | +
|
| 151 | + - name: Set up JDK 11 |
| 152 | + uses: actions/setup-java@v2 |
| 153 | + with: |
| 154 | + distribution: 'temurin' |
| 155 | + java-version: '11' |
| 156 | + java-package: jdk |
| 157 | + |
| 158 | + - name: Build dependencies/licenses files |
| 159 | + run: mvn -B project-info-reports:dependencies -Pjava8 |
| 160 | + |
| 161 | + - name: Upload licenses - Upload Artifact |
| 162 | + uses: actions/upload-artifact@v2 |
| 163 | + with: |
| 164 | + name: dependencies-licenses |
| 165 | + path: target/site |
| 166 | + |
| 167 | + - name: Generate docs/dependencies dir |
| 168 | + run: mkdir -p docs/dependencies |
| 169 | + |
| 170 | + - name: Move built files into docs/dependencies |
| 171 | + run: mv target/site/* docs/dependencies |
| 172 | + |
| 173 | + - name: Rename dependencies.html to index.html |
| 174 | + working-directory: docs/dependencies |
| 175 | + run: mv dependencies.html index.html |
| 176 | + |
| 177 | + - name: Copy Readme into docs (as index.md) |
| 178 | + run: cp README.md docs/index.md |
| 179 | + |
| 180 | + - name: Configure Pages |
| 181 | + working-directory: docs |
| 182 | + run: |- |
| 183 | + echo "theme: jekyll-theme-tactile" > _config.yml |
| 184 | +
|
| 185 | + - name: Deploy to Github pages |
| 186 | + uses: peaceiris/actions-gh-pages@v3 |
| 187 | + with: |
| 188 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 189 | + publish_dir: ./docs |
| 190 | + enable_jekyll: true |
| 191 | + |
| 192 | + build_xdev_ide: |
| 193 | + runs-on: ubuntu-latest |
| 194 | + needs: [prepare_release] |
| 195 | + steps: |
| 196 | + - uses: actions/checkout@v2 |
| 197 | + |
| 198 | + - name: Init Git and pull |
| 199 | + run: | |
| 200 | + git config --global user.email "actions@github.com" |
| 201 | + git config --global user.name "GitHub Actions" |
| 202 | + git pull |
| 203 | + |
| 204 | + - name: Set up JDK |
| 205 | + uses: actions/setup-java@v2 |
| 206 | + with: |
| 207 | + distribution: 'zulu' |
| 208 | + java-version: '8' |
| 209 | + java-package: jdk+fx |
| 210 | + |
| 211 | + - name: Cache local Maven repository |
| 212 | + uses: actions/cache@v2 |
| 213 | + with: |
| 214 | + path: ~/.m2/repository |
| 215 | + key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} |
| 216 | + restore-keys: | |
| 217 | + ${{ runner.os }}-maven- |
| 218 | + |
| 219 | + - name: Build with Maven |
| 220 | + run: mvn -B clean verify -Pjava8,xdev-ide |
| 221 | + |
| 222 | + - uses: actions/upload-artifact@v2 |
| 223 | + with: |
| 224 | + name: jars-xdev-ide |
| 225 | + path: target/*.jar |
| 226 | + |
| 227 | + after_release: |
| 228 | + runs-on: ubuntu-latest |
| 229 | + needs: [publish_central, build_xdev_ide] |
| 230 | + steps: |
| 231 | + - uses: actions/checkout@v2 |
| 232 | + |
| 233 | + - name: Init Git and pull |
| 234 | + run: | |
| 235 | + git config --global user.email "actions@github.com" |
| 236 | + git config --global user.name "GitHub Actions" |
| 237 | + git pull |
| 238 | + |
| 239 | + - name: Inc Version and SNAP root |
| 240 | + # The versions plugin doesn't work that easily with maven so there are some workarounds |
| 241 | + run: | |
| 242 | + echo "Setting version without suffix" |
| 243 | + read_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 244 | + parts=(${read_version//-/ }) |
| 245 | + mvn versions:set -DnewVersion=${parts[0]} -DgenerateBackupPoms=false |
| 246 | + |
| 247 | + echo "Incrementing version and set snapshot" |
| 248 | + mvn versions:set -DnextSnapshot=true -DgenerateBackupPoms=false |
| 249 | + |
| 250 | + echo "Set version with suffix" |
| 251 | + read_version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 252 | + parts=(${read_version//-/ }) |
| 253 | + mvn versions:set -DnewVersion="${parts[0]}-{version.suffix}-${parts[1]}" -DgenerateBackupPoms=false |
| 254 | + |
| 255 | + - name: Git Commit and Push |
| 256 | + run: | |
| 257 | + git add -A |
| 258 | + git commit -m "Preparing for next development iteration" |
| 259 | + git push origin |
| 260 | + |
| 261 | + - name: pull-request |
| 262 | + uses: repo-sync/pull-request@v2 |
| 263 | + with: |
| 264 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 265 | + destination_branch: "develop" |
| 266 | + pr_title: "Sync back" |
| 267 | + pr_body: "An automated PR to sync changes back" |
0 commit comments