Skip to content

Commit

Permalink
Add reusable public gh actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dweiss committed Oct 15, 2024
0 parents commit ec232de
Show file tree
Hide file tree
Showing 6 changed files with 216 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/actions/create-and-tag-release/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: "Create a release tag and github release"
description: "Create a release tag and github release"

inputs:
tag:
description: 'Release tag (e.g. release/2.0.1)'
required: true

name:
description: 'Release name, leave empty to use tag'
required: false

removeExistingReleaseAndTag:
description: 'Remove existing release and tag'
type: boolean
required: false
default: false

artifacts:
description: 'A glob or paths to artifacts to include in the release (e.g., releases/*)'
required: true

token:
description: "Github token."
required: false

runs:
using: "composite"
steps:
- name: Remove existing release and tag
if: ${{ inputs.removeExistingReleaseAndTag }}
shell: bash
run: |
if gh release delete "${{ inputs.tag }}" --yes --cleanup-tag; then
echo "Release deleted: ${{ inputs.tag }}"
# Wait a bit so that the deletion is confirmed and propagates.
sleep 5
else
echo "::warning::Can't delete an existing release with this tag: ${{ inputs.tag }}?"
gh release list
fi
env:
GH_TOKEN: ${{ inputs.token || github.token }}

- name: Create release
uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5
with:
draft: false
commit: ${{ github.ref }}
tag: ${{ inputs.tag }}
name: ${{ inputs.name }}
artifacts: ${{ inputs.artifacts }}
allowUpdates: false
artifactErrorsFailBuild: true
generateReleaseNotes: true
token: ${{ inputs.token || github.token }}
47 changes: 47 additions & 0 deletions .github/actions/download-release-artifacts/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Download release artifacts
description: Download one or more artifacts (reusable infra action)

inputs:
release:
description: "Release to download. Default 'latest'. If not 'latest', this has to be in the form tags/<tag_name> or <release_id>"
required: true

dir:
description: "Target directory to write artifacts to."
required: true

repo:
description: "The `org/repo` containing the release. Defaults to the current repo."
required: false

pattern:
description: "Regexp pattern to match artifact names."
default: "^.*$"
required: false

token:
description: "Github token."
required: false

runs:
using: "composite"
steps:
- name: Create release artifact folders
shell: bash
run: |
mkdir -p ${{ inputs.dir }}
- name: Fetch release artifacts
uses: dweiss/fetch-gh-release-asset@v1
with:
repo: ${{ inputs.repo }}
version: ${{ inputs.release }}
file: ${{ inputs.pattern }}
regex: true
target: ${{ inputs.dir }}
token: ${{ inputs.token || github.token }}

- name: List downloaded release files
shell: bash
run: |
ls -al ${{ inputs.dir }}
21 changes: 21 additions & 0 deletions .github/actions/prepare-git-clone/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Prepare local git clone"
description: "Prepare local git clone"

inputs:
token:
description: "Github token."
required: false

runs:
using: "composite"
steps:
- name: Correct git autocrlf
shell: bash
run: git config --global core.autocrlf false

- name: Git checkout
uses: actions/checkout@v4
with:
fetch-depth: 1
submodules: recursive
token: ${{ inputs.token || github.token }}
47 changes: 47 additions & 0 deletions .github/actions/prepare-gradle-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: "Prepare Gradle and Java build"
description: "Prepare Gradle and Java build"

inputs:
jdk-version:
required: true
description: "JDK version to set up"

jdk-distribution:
required: false
default: "temurin"
description: "JDK distribution"

runs:
using: "composite"
steps:
- name: "Set up JDK (${{ inputs.jdk-distribution }}, ${{ inputs.jdk-version }}) [buildjet]"
if: ${{ contains(runner.name, 'buildjet') }}
uses: buildjet/setup-java@v4
with:
distribution: ${{ inputs.jdk-distribution }}
java-version: ${{ inputs.jdk-version }}
java-package: jdk

- name: "Set up JDK (${{ inputs.jdk-distribution }}, ${{ inputs.jdk-version }}) [blacksmith]"
if: ${{ contains(runner.name, 'blacksmith') }}
uses: useblacksmith/setup-java@v5
with:
distribution: ${{ inputs.jdk-distribution }}
java-version: ${{ inputs.jdk-version }}
java-package: jdk

- name: "Set up JDK (${{ inputs.jdk-distribution }}, ${{ inputs.jdk-version }}) [github]"
if: ${{ !contains(runner.name, 'buildjet') && !contains(runner.name, 'blacksmith') }}
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.jdk-distribution }}
java-version: ${{ inputs.jdk-version }}
java-package: jdk

- name: Setup Gradle [blacksmith]
if: ${{ contains(runner.name, 'blacksmith') }}
uses: useblacksmith/setup-gradle/setup-gradle@v5

- name: Setup Gradle
if: ${{ !contains(runner.name, 'buildjet') && !contains(runner.name, 'blacksmith') }}
uses: gradle/actions/setup-gradle@v3
39 changes: 39 additions & 0 deletions .github/actions/prepare-java-build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: "Prepare Java build"
description: "Prepare Java build"

inputs:
jdk-version:
required: true
description: "JDK version to set up"

jdk-distribution:
required: false
default: "temurin"
description: "JDK distribution"

runs:
using: "composite"
steps:
- name: "Set up JDK (${{ inputs.jdk-distribution }}, ${{ inputs.jdk-version }}) [buildjet]"
if: ${{ contains(runner.name, 'buildjet') }}
uses: buildjet/setup-java@v4
with:
distribution: ${{ inputs.jdk-distribution }}
java-version: ${{ inputs.jdk-version }}
java-package: jdk

- name: "Set up JDK (${{ inputs.jdk-distribution }}, ${{ inputs.jdk-version }}) [blacksmith]"
if: ${{ contains(runner.name, 'blacksmith') }}
uses: useblacksmith/setup-java@v5
with:
distribution: ${{ inputs.jdk-distribution }}
java-version: ${{ inputs.jdk-version }}
java-package: jdk

- name: "Set up JDK (${{ inputs.jdk-distribution }}, ${{ inputs.jdk-version }}) [github]"
if: ${{ !contains(runner.name, 'buildjet') && !contains(runner.name, 'blacksmith') }}
uses: actions/setup-java@v4
with:
distribution: ${{ inputs.jdk-distribution }}
java-version: ${{ inputs.jdk-version }}
java-package: jdk
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"

0 comments on commit ec232de

Please sign in to comment.