Skip to content

Commit

Permalink
Update github actions
Browse files Browse the repository at this point in the history
  • Loading branch information
pmendelski committed Sep 29, 2024
1 parent 267ccc4 commit 45adf2c
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 54 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Skip duplicates and docs
id: skip
Expand All @@ -18,11 +18,11 @@ jobs:

- name: Validate gradle wrapper
if: steps.skip.outputs.should_skip != 'true'
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@v3

- name: Setup JDK
if: steps.skip.outputs.should_skip != 'true'
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
cache: gradle
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@v4
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"

Expand All @@ -22,7 +22,7 @@ jobs:
steps:
- name: Dependabot metadata
id: dependabot-metadata
uses: dependabot/fetch-metadata@v2.2.0
uses: dependabot/fetch-metadata@v2

- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --rebase "$PR_URL"
Expand Down
49 changes: 27 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,15 @@ on:
type: string
description: |
Release version in semantic format (like: 1.2.3).
No value means a new patch version.
Releases from non-default branch will bu suffixed with -SNAPSHOT (like: 1.2.3-SNAPSHOT).
Default: next patch version.
required: false
publish:
type: choice
branch:
type: string
description: |
Artifact publication.
Use for creating draft release notes.
options:
- SKIP
- RELEASE
Branch name with source code changes.
required: true
default: RELEASE
default: master
release:
types: [published]

Expand All @@ -40,16 +37,18 @@ jobs:
fi
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ inputs.branch }}
token: ${{ secrets.CI_TOKEN }}

- name: Get versions
id: versions
env:
NEXT_INPUT_VERSION: ${{ inputs.version }}
TAG_NAME: ${{ github.event.release.tag_name }}
BRANCH: ${{ inputs.branch }}
run: |
declare -r GIT_VERSION="$(git tag -l 'v[0-9]*.[0-9]*.[0-9]*' | sort -V | tail -n 1 | cut -c2-)"
declare -r VERSION=${GIT_VERSION:-0.0.0}
Expand All @@ -59,16 +58,21 @@ jobs:
declare -r NEXT_TAG_VERSION="$([[ "$TAG_NAME" =~ v.* ]] \
&& (echo "$TAG_NAME" | cut -c2-) \
|| echo "$TAG_NAME")"
declare -r NEXT_MANUAL_VERSION="${NEXT_INPUT_VERSION:-$NEXT_TAG_VERSION}"
declare -r SUFFIX="$([ "$BRANCH" == "master" ] \
&& echo "" \
|| echo "-SNAPHOT")"
declare -r NEXT_INPUT_VERSION_SANITIZED="${NEXT_INPUT_VERSION%$SUFFIX}"
declare -r NEXT_MANUAL_VERSION="${NEXT_INPUT_VERSION_SANITIZED:-$NEXT_TAG_VERSION}"
declare -r NEXT_PATCH_VERSION="$MAJOR.$MINOR.$(( $PATCH + 1 ))"
declare -r NEXT_VERSION="${NEXT_MANUAL_VERSION:-$NEXT_PATCH_VERSION}"
declare -r NEXT_VERSION="${NEXT_MANUAL_VERSION:-$NEXT_PATCH_VERSION}-$SUFFIX"
echo ::set-output name=version::$VERSION
echo ::set-output name=next_version::$NEXT_VERSION
echo -e "VERSION: $VERSION\nNEXT_VERSION: $NEXT_VERSION"
- name: Import GPG key
id: gpg
uses: crazy-max/ghaction-import-gpg@v5
uses: crazy-max/ghaction-import-gpg@v6
if: |
github.event_name != 'release'
&& github.ref == 'refs/heads/master'
Expand All @@ -81,7 +85,9 @@ jobs:
git_committer_email: bot@coditory.com

- name: Update version in README (master only)
if: steps.gpg.conclusion == 'success'
if: |
inputs.branch == 'master'
&& steps.gpg.conclusion == 'success'
env:
PREV_VERSION: ${{ steps.versions.outputs.version }}
NEXT_VERSION: ${{ steps.versions.outputs.next_version }}
Expand All @@ -98,17 +104,14 @@ jobs:
fi
- name: Setup JDK
if: inputs.publish != 'SKIP'
uses: actions/setup-java@v3
uses: actions/setup-java@v4
with:
java-version: 17
cache: gradle
distribution: temurin

- name: Publish to Gradle Plugin Portal
if: |
github.event_name == 'release'
|| inputs.publish == 'RELEASE'
if: github.event_name == 'release'
env:
GRADLE_PUBLISH_KEY: ${{ secrets.GRADLE_PUBLISH_KEY }}
GRADLE_PUBLISH_SECRET: ${{ secrets.GRADLE_PUBLISH_SECRET }}
Expand All @@ -122,7 +125,8 @@ jobs:
- name: Generate release notes
id: notes
if: |
github.event_name != 'release'
inputs.branch == 'master'
&& github.event_name != 'release'
&& github.ref == 'refs/heads/master'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -141,11 +145,12 @@ jobs:
echo ::set-output name=notes::$ESCAPED
- name: Create github release (master only)
if: steps.notes.conclusion == 'success'
if: |
inputs.branch == 'master'
&& steps.notes.conclusion == 'success'
uses: ncipollo/release-action@v1
with:
allowUpdates: true
body: ${{ steps.notes.outputs.notes }}
draft: ${{ inputs.publish == 'SKIP' }}
tag: v${{ steps.versions.outputs.next_version }}
token: ${{ secrets.GITHUB_TOKEN }}
27 changes: 0 additions & 27 deletions .github/workflows/stale.yml

This file was deleted.

0 comments on commit 45adf2c

Please sign in to comment.