chore(deps): update dependency gradle to v8.12 (#324) #2093
This file contains 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: test-and-deploy | |
on: | |
push: | |
branches-ignore: | |
- renovate/** | |
pull_request: | |
jobs: | |
tests: | |
defaults: | |
run: | |
shell: bash | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-24.04 | |
# - windows | |
- macos-14 | |
runs-on: ${{ matrix.os }} | |
concurrency: | |
group: ${{ github.workflow }}-test-${{ matrix.os }}-${{ github.event.number || github.ref }} | |
steps: | |
- name: Setup Java | |
uses: actions/[email protected] | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Setup WSL | |
if: runner.os == 'Windows' | |
uses: Vampire/[email protected] | |
with: | |
distribution: Ubuntu-22.04 | |
- name: Configure WSL | |
if: runner.os == 'Windows' | |
shell: wsl-bash {0} | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y openjdk-21-jre-headless | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Tests | |
run: ./tests.main.kts | |
prepare-deliveries: | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.deliveries.outputs.matrix }} | |
steps: | |
- name: Setup Java | |
uses: actions/[email protected] | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: Compute ref | |
id: ref | |
run: | | |
ruby -e '\ | |
if "${{ github.event_name }}" == "push" && "${{ github.event.ref }}".end_with?("/master") then | |
puts "::set-output name=ref::${{ github.event.after }}" | |
else | |
puts "::set-output name=ref::master" | |
end | |
' | |
- name: Checkout | |
uses: actions/[email protected] | |
with: | |
fetch-depth: 0 | |
ref: ${{ steps.ref.outputs.ref }} | |
submodules: recursive | |
- name: Prepare deliverable packages | |
id: deliveries | |
run: ./deployer.main.kts | |
- name: Tar files | |
run: tar -cvf build.tar build | |
- name: Upload artifact | |
uses: actions/[email protected] | |
with: | |
name: build | |
path: build.tar | |
delivery: | |
needs: | |
- tests # Don't deliver if testing fails | |
- prepare-deliveries | |
runs-on: ubuntu-latest | |
if: >- | |
!github.event.repository.fork | |
&& ( | |
github.event_name != 'pull_request' | |
|| github.event.pull_request.head.repo.full_name == github.repository | |
) | |
strategy: | |
fail-fast: false | |
matrix: ${{ fromJSON(needs.prepare-deliveries.outputs.matrix) }} | |
max-parallel: 1 | |
concurrency: | |
group: ${{ github.workflow }}-delivery-${{ matrix.type }}-${{ matrix.ref }}-${{ matrix.target }}-${{ matrix.owner }}-${{ matrix.repo }}-${{ github.event.number || github.ref }} | |
cancel-in-progress: false | |
steps: | |
- name: Checkout the local repo | |
if: matrix.type == 'repo' | |
uses: actions/[email protected] | |
- name: Checkout the target repo if it exists, initialize if needed | |
if: matrix.type == 'repo' | |
run: | | |
git clone https://${{ secrets.DEPLOYMENT_TOKEN }}@github.com/${{ matrix.owner }}/${{ matrix.repo }} target | |
cd target | |
git checkout ${{ matrix.ref }} || git checkout ${{ matrix.ref }} origin/${{ matrix.ref }} || git checkout -b ${{ matrix.ref }} | |
if ! git rev-parse HEAD &> /dev/null; then | |
echo 'The repository is empty, creating the target branch and adding a first commit' | |
git config user.name 'pianinator[bot]' | |
git config user.email '[email protected]' | |
git commit --allow-empty -m 'initialize the repository' | |
fi | |
- name: Check if the branch can release | |
id: can-release | |
run: | | |
echo "can-release=${{endsWith(github.ref, '/master') || endsWith(github.ref, '/exercises')}}" >> $GITHUB_OUTPUT | |
- name: Push the repo | |
if: matrix.type == 'repo' && steps.can-release.outputs.can-release == 'true' | |
working-directory: target | |
run: | | |
git push -u origin ${{ matrix.ref }} | |
- name: Download artifact | |
uses: actions/[email protected] | |
with: | |
name: build | |
- name: Unpack | |
run: tar -xf build.tar | |
- name: Deliver an archive | |
if: matrix.type == 'release' && steps.can-release.outputs.can-release == 'true' | |
uses: ncipollo/[email protected] | |
with: | |
allowUpdates: true | |
artifacts: ${{ matrix.target }} | |
owner: ${{ matrix.owner }} | |
repo: ${{ matrix.repo }} | |
replacesArtifacts: true | |
tag: ${{ matrix.ref }} | |
token: ${{ secrets.DEPLOYMENT_TOKEN }} | |
- name: Deliver a branch | |
if: matrix.type == 'repo' && steps.can-release.outputs.can-release == 'true' | |
uses: JamesIves/[email protected] | |
with: | |
folder: ${{ matrix.target }} | |
token: ${{ secrets.DEPLOYMENT_TOKEN }} | |
branch: ${{ matrix.ref }} | |
repository-name: ${{ matrix.owner }}/${{ matrix.repo }} | |
success: | |
runs-on: ubuntu-24.04 | |
needs: | |
- delivery | |
- tests | |
if: >- | |
always() && ( | |
contains(join(needs.*.result, ','), 'failure') | |
|| !contains(join(needs.*.result, ','), 'cancelled') | |
) | |
steps: | |
- name: Verify that there were no failures | |
run: ${{ !contains(join(needs.*.result, ','), 'failure') }} |