Skip to content

👷 push prebuilt snapshot #26

👷 push prebuilt snapshot

👷 push prebuilt snapshot #26

Workflow file for this run

name: Build
on:
push:
branches:
- "main"
paths-ignore:
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'
- '*.md'
pull_request:
paths-ignore:
- '.gitignore'
- 'CODEOWNERS'
- 'LICENSE'
- '*.md'
env:
JAVA_VERSION: 21
JAVA_DISTRO: temurin
GH_BOT_EMAIL: "41898282+github-actions[bot]@users.noreply.github.com"
GH_BOT_NAME: "GitHub Action"
GRAALVM_DIST: graalvm-community
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: 21
distribution: 'temurin'
cache: maven
- name: Project metadata
id: metadata
run: |
SNAPSHOT=$(yq '.release.snapshot-version' .github/project.yml)
ARTIFACT=$(yq '.build.artifact' .github/project.yml)
echo "snapshot=${SNAPSHOT}" >> $GITHUB_OUTPUT
echo "artifact=${ARTIFACT}" >> $GITHUB_OUTPUT
- name: Build with Maven
run: |
./mvnw -B -ntp formatter:validate verify
- name: Build and run in native mode
id: mvn-native-build
env:
MAVEN_OPTS: "-Xmx1g"
run: |
./mvnw -B -ntp verify -DskipTests -DskipFormat \
-Dnative \
-Dquarkus.native.container-build=true \
-Dquarkus.container-image.build=true
- name: Update release with snapshot artifact
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }}
id: mvn-release-snapshot
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SNAPSHOT: ${{ steps.metadata.outputs.snapshot }}
run: |
git config user.name ${{ env.GH_BOT_NAME }}
git config user.email ${{ env.GH_BOT_EMAIL }}
ls -al target
AV=${{ steps.metadata.outputs.artifact }}-${{ steps.metadata.outputs.snapshot }}
gh release upload "${SNAPSHOT}" --clobber ./target/${AV}.jar#${AV}.jar
gh release upload "${SNAPSHOT}" --clobber ./target/${AV}-runner#${AV}-runner
echo "Update tag for $SNAPSHOT"
git push origin :refs/tags/$SNAPSHOT
git tag -f $SNAPSHOT
git push --tags
echo "Update $SNAPSHOT release"
gh release edit "${SNAPSHOT}" -t "${SNAPSHOT}" --prerelease
- name: Log in to the Container registry
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }}
uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish OCI (native)
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }}
id: publish-oci
env:
SNAPSHOT: ${{ steps.metadata.outputs.snapshot }}
run: |
image="commonhaus/commonhaus-bot:${SNAPSHOT}"
docker tag "${image}" "ghcr.io/${image}"
docker push "ghcr.io/commonhaus/commonhaus-bot:${SNAPSHOT}"
- name: Mark snapshot release as non-draft
if: ${{ github.event_name == 'push' && github.repository == 'commonhaus/automation' }}
id: update-snapshot-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SNAPSHOT: ${{ steps.metadata.outputs.snapshot }}
run: |
gh release edit "${SNAPSHOT}" --draft=false
gh release view "${SNAPSHOT}"