Build #422
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | |
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| schedule: | |
| - cron: '0 0 * * *' | |
| jobs: | |
| check-copyright: | |
| name: Check Copyright | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Check Copyright | |
| env: | |
| EXTENSIONS: "*.java" | |
| BASE_COPYRIGHT: "Copyright IBM Corp. 2016" | |
| run: | | |
| for ext in "$EXTENSIONS"; do | |
| for file in $(find . -type f -name "$ext" -path "./cics-java-liberty-link-app/*"); do | |
| echo "Processing file: $file" | |
| LAST_MODIFIED_YEAR=$(git log --follow -1 --format="%ad" --date=format:"%Y" -- "$file") | |
| if ! grep -q "Copyright" "$file"; then | |
| echo -e "/**\n * $BASE_COPYRIGHT\n */\n$(cat "$file")" > "$file" | |
| else | |
| # Extract existing copyright line | |
| CURRENT_COPYRIGHT=$(grep -o "Copyright IBM Corp. [0-9]\{4\}\(, [0-9]\{4\}\)\?" "$file") | |
| # Check if LAST_MODIFIED_YEAR is anywhere in current copyright | |
| if [[ "$CURRENT_COPYRIGHT" != *"$LAST_MODIFIED_YEAR"* ]]; then | |
| # Check if copyright has two years | |
| if [[ "$CURRENT_COPYRIGHT" =~ ,\ [0-9]{4}$ ]]; then | |
| # If there is already a second year, replace it | |
| sed -i "s/$BASE_COPYRIGHT, [0-9]\{4\}/$BASE_COPYRIGHT, $LAST_MODIFIED_YEAR/" "$file" | |
| else | |
| # If there is no second year, add it | |
| sed -i "s/$BASE_COPYRIGHT/$BASE_COPYRIGHT, $LAST_MODIFIED_YEAR/" "$file" | |
| fi | |
| fi | |
| fi | |
| done | |
| done | |
| - name: Create Pull Request | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| base: ${{ github.head_ref }} | |
| build-mvnw: | |
| name: Build Maven Wrapper | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| jdk: [8, 11, 17, 21] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK ${{ matrix.jdk }} | |
| uses: actions/setup-java@v3 | |
| with: | |
| java-version: ${{ matrix.jdk }} | |
| distribution: "semeru" | |
| cache: maven | |
| - name: Build with Maven | |
| run: ./mvnw --batch-mode --update-snapshots --file pom.xml -Djava.version=${{ matrix.jdk }} verify | |
| build-gradlew: | |
| name: Build Gradle Wrapper | |
| runs-on: ubuntu-latest | |
| strategy: | |
| matrix: | |
| jdk: [8, 11, 17, 21] | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Set up JDK ${{ matrix.jdk }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: ${{ matrix.jdk }} | |
| distribution: 'semeru' | |
| - uses: gradle/actions/setup-gradle@v3 | |
| with: | |
| gradle-version: 8.6 | |
| - name: Build with Gradle | |
| run: ./gradlew clean build -Pjava_version=${{ matrix.jdk }} |