Skip to content

Publish snapshots on every push #338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: neo
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 19 additions & 18 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
name: Publish to GitHub packages
name: Publish Snapshot

on:
push:
branches:
- neo
workflow_dispatch:

env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}

jobs:
publish-snapshot:
name: Publish Snapshot to GitHub Packages
runs-on: ubuntu-24.04

permissions:
contents: read
packages: write
Expand All @@ -23,32 +24,32 @@ jobs:
- name: Set up Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
java-version: 8
distribution: temurin

- name: Set up Gradle
uses: gradle/actions/setup-gradle@v4

- name: Generate snapshot version
id: version
id: snapshot_version
run: |
DATE=$(date +'%Y%m%d')
COMMIT_HASH=$(git rev-parse --short HEAD)
SNAPSHOT_VERSION="${DATE}+${COMMIT_HASH}"
echo "snapshot_version=${SNAPSHOT_VERSION}" >> $GITHUB_OUTPUT
echo "Generated snapshot version: ${SNAPSHOT_VERSION}"
echo "::notice title=Snapshot Version::${SNAPSHOT_VERSION}"
# Replace non-alphanumeric characters in branch name with hyphens
SAFE_BRANCH=$(echo "${BRANCH_NAME}" | sed 's#[^A-Za-z0-9._-]#-#g')
SHORT_SHA=$(echo "${GITHUB_SHA}" | cut -c1-8)
VERSION="${SAFE_BRANCH}+${SHORT_SHA}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "::notice title=Snapshot Version::Generated snapshot version: ${VERSION}"

- name: Publish snapshot
run: ./gradlew publish -Pversion=${{ steps.version.outputs.snapshot_version }}
run: ./gradlew publish -Pversion=${{ steps.snapshot_version.outputs.version }}
env:
GITHUB_ACTOR: ${{ github.actor }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Write summary
run: |
echo "## 📦 Snapshot Published" >> $GITHUB_STEP_SUMMARY
echo "**Version:** \`${{ steps.version.outputs.snapshot_version }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** \`${{ github.sha }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Repository:** GitHub Packages" >> $GITHUB_STEP_SUMMARY
echo "**Project:** \`${{ github.repository }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Version:** \`${{ steps.snapshot_version.outputs.version }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** \`${BRANCH_NAME}\`" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** \`${GITHUB_SHA}\`" >> $GITHUB_STEP_SUMMARY
Loading