Skip to content

Bump the github-actions group with 3 updates #68

Bump the github-actions group with 3 updates

Bump the github-actions group with 3 updates #68

name: Botz CI
env:
CI: true
on: [push, pull_request]
jobs:
build:
name: Build Botz from source
runs-on: ubuntu-latest
strategy:
matrix:
java: [ 11, 17 ]
steps:
- uses: actions/checkout@v6
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v5
with:
distribution: temurin
java-version: ${{ matrix.java }}
- name: Cache Maven repository
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-java${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-java${{ matrix.java }}-maven-
${{ runner.os }}-
- name: Build with Maven
run: mvn -B package --file pom.xml
- name: Upload distribution
uses: actions/upload-artifact@v6
with:
name: distribution-java${{ matrix.java }}
path: target/botz-*.jar
check_branch:
runs-on: ubuntu-latest
outputs:
is_publishable_branch: ${{ steps.check-branch.outputs.is_publishable_branch }}
steps:
- name: check branch ${{ github.ref }} is either main or a version number
id: check-branch
run: |
if [[ ${{ github.ref }} == 'refs/heads/main' || ${{ github.ref }} =~ refs\/heads\/[0-9]+\.[0-9]+ ]]; then
echo "is_publishable_branch=true" >> $GITHUB_OUTPUT
else
echo "is_publishable_branch=false" >> $GITHUB_OUTPUT
fi
publish-maven:
name: Publish to Maven
runs-on: ubuntu-latest
needs: [build, check_branch]
if: ${{github.repository == 'igniterealtime/Botz' && github.event_name == 'push' && ( needs.check_branch.outputs.is_publishable_branch == 'true' || contains(github.ref, 'refs/tags/') ) }}
steps:
- uses: actions/checkout@v6
with:
# Defend against another commit quickly following the first
# We want the one that's been tested, rather than the head of main
ref: ${{ github.event.push.after }}
- id: get-id
name: Compute needed variables
run: |
set -x
tag=$(echo ${{ github.ref }} | cut -d '/' -f3)
echo "tag=$tag" >> $GITHUB_OUTPUT
echo "tag is '$tag'"
version=$(echo ${{ github.ref }} | cut -d '/' -f3 | cut -c 2-)
echo "version=$version" >> $GITHUB_OUTPUT
echo "version is '$version'"
rel_id=$(curl -sL --header 'authorization: Bearer ${{ secrets.GITHUB_TOKEN }}' https://api.github.com/repos/${{github.repository}}/releases | jq -r --arg TAG "$tag" '.[] | select(.tag_name==$TAG) | .id')
echo "rel_id=$rel_id" >> $GITHUB_OUTPUT
echo "rel_id is '$rel_id'"
- name: Cache Maven repository
uses: actions/cache@v5
with:
path: ~/.m2/repository
key: ${{ runner.os }}-java11-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-java11-maven-
${{ runner.os }}-
- name: Set up Java for publishing
uses: actions/setup-java@v5
with:
java-version: 11
distribution: temurin
server-id: igniterealtime
server-username: IGNITE_REALTIME_MAVEN_USERNAME
server-password: IGNITE_REALTIME_MAVEN_PASSWORD
- name: Publish
run: mvn -B -Dmaven.resolver.transport=wagon deploy
env:
IGNITE_REALTIME_MAVEN_USERNAME: ${{ secrets.IGNITE_REALTIME_MAVEN_USERNAME }}
IGNITE_REALTIME_MAVEN_PASSWORD: ${{ secrets.IGNITE_REALTIME_MAVEN_PASSWORD }}
- name: Push Artifact to Github Release
uses: actions/upload-release-asset@v1
if: ${{ contains(github.ref, 'refs/tags/') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.get-id.outputs.rel_id }}/assets?name=botz-${{ steps.get-id.outputs.version }}.jar
asset_path: target/botz-${{ steps.get-id.outputs.version }}.jar
asset_name: botz-${{ steps.get-id.outputs.version }}.jar
asset_content_type: application/java-archive