generated from LizardByte/template-base
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3c1c4f
commit 704c46a
Showing
6 changed files
with
205 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
--- | ||
name: CI | ||
|
||
on: | ||
pull_request: | ||
branches: [master] | ||
types: [opened, synchronize, reopened] | ||
push: | ||
branches: [master] | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
action: | ||
environment: | ||
${{ github.event_name == 'pull_request' && | ||
github.event.pull_request.head.repo.full_name != github.repository && | ||
'external' || 'internal' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup Release | ||
id: setup_release | ||
uses: LizardByte/[email protected] | ||
with: | ||
fail_on_events_api_error: # PRs will fail if this is true | ||
${{ github.event_name == 'pull_request' && 'false' || 'true' }} | ||
github_token: ${{ secrets.GITHUB_TOKEN }} # can use GITHUB_TOKEN for read-only access | ||
|
||
- name: Modify Homebrew Formula | ||
# ensure the file is unique | ||
run: | | ||
echo "# Created from ${{ github.repository }}@${{ github.sha }}" >> ./tests/Formula/hello_world.rb | ||
- name: Run Action | ||
id: action | ||
uses: ./ | ||
with: | ||
git_email: ${{ secrets.GH_BOT_EMAIL }} | ||
git_username: ${{ secrets.GH_BOT_NAME }} | ||
local_repo_directory: ${{ github.workspace }}/tests | ||
target_repo: ${{ github.repository }} | ||
target_repo_branch: tests | ||
token: ${{ secrets.GH_BOT_TOKEN }} | ||
|
||
- name: Create/Update GitHub Release | ||
if: ${{ steps.setup_release.outputs.publish_release == 'true' }} | ||
uses: LizardByte/[email protected] | ||
with: | ||
allowUpdates: true | ||
body: '' | ||
discussionCategory: announcements | ||
generateReleaseNotes: true | ||
name: ${{ steps.setup_release.outputs.release_tag }} | ||
prerelease: ${{ steps.setup_release.outputs.publish_pre_release }} | ||
tag: ${{ steps.setup_release.outputs.release_tag }} | ||
token: ${{ secrets.GH_BOT_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# ignore jetbrains files | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 LizardByte | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,39 @@ | ||
# template-base | ||
Base repository template for LizardByte. | ||
# homebrew-release-action | ||
[![GitHub Workflow Status (CI)](https://img.shields.io/github/actions/workflow/status/lizardbyte/homebrew-release-action/ci.yml.svg?branch=master&label=CI%20build&logo=github&style=for-the-badge)](https://github.com/LizardByte/homebrew-release-action/actions/workflows/ci.yml?query=branch%3Amaster) | ||
|
||
A reusable action to publish homebrew formulas to a tap. | ||
This action is tailored to the @LizardByte organization, but can be used by anyone if they follow the same conventions. | ||
|
||
## Basic Usage | ||
|
||
See [action.yml](action.yml) | ||
|
||
The intent here is that the formulas are built in the upstream repository, instead of the tap repository. | ||
|
||
As part of an automated release workflow, this action can be used to upload the built formulas to the tap repository. | ||
|
||
```yaml | ||
steps: | ||
- name: Publish Homebrew Formula | ||
uses: LizardByte/homebrew-release-action@master | ||
with: | ||
git_email: ${{ secrets.GIT_EMAIL }} | ||
git_username: ${{ secrets.GIT_USERNAME }} | ||
target_repo: repo_owner/repo_name | ||
token: ${{ secrets.PAT }} | ||
``` | ||
It's possible to overwrite the defaults by providing additional inputs: | ||
```yaml | ||
steps: | ||
- name: Publish Homebrew Formula | ||
uses: LizardByte/homebrew-release-action@master | ||
with: | ||
local_repo_directory: "${{ github.workspace }}/homebrew-repo" | ||
git_email: ${{ secrets.GIT_EMAIL }} | ||
git_username: ${{ secrets.GIT_USERNAME }} | ||
target_repo: repo_owner/repo_name | ||
target_repo_branch: master | ||
token: ${{ secrets.PAT }} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
--- | ||
name: "Homebrew Release" | ||
description: "A reusable action to publish a Homebrew formula to a tap." | ||
author: "LizardByte" | ||
inputs: | ||
local_repo_directory: | ||
description: 'The location of the local directory. If the default is not used, you must pass the entire path.' | ||
default: "homebrew" | ||
required: false | ||
git_email: | ||
description: 'The email to use for the commit.' | ||
required: true | ||
git_username: | ||
description: 'The username to use for the commit.' | ||
required: true | ||
target_repo: | ||
description: 'The target repository to publish to.' | ||
default: 'LizardByte/homebrew' | ||
required: false | ||
target_repo_branch: | ||
description: 'The target repository branch to publish to.' | ||
default: '' | ||
required: false | ||
token: | ||
description: 'Github Token.' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout database | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: ${{ inputs.target_repo }} | ||
ref: ${{ inputs.target_repo_branch }} | ||
path: ${{ github.action_path }}/build | ||
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token | ||
fetch-depth: 0 # otherwise, will fail to push refs to dest repo | ||
|
||
- name: Prepare Homebrew repo | ||
shell: bash | ||
run: | | ||
if [ "${{ inputs.local_repo_directory }}" == "homebrew" ]; then | ||
source_path="${{ github.workspace }}/${{ inputs.local_repo_directory }}" | ||
else | ||
source_path="${{ inputs.local_repo_directory }}" | ||
fi | ||
# copy local repo to target repo | ||
cp -f -r ${source_path}/. ${{ github.action_path }}/build/ | ||
- name: GitHub Commit & Push | ||
uses: actions-js/[email protected] | ||
with: | ||
author_email: ${{ inputs.git_email }} | ||
author_name: ${{ inputs.git_username }} | ||
branch: ${{ inputs.target_repo_branch }} # commit to target branch | ||
directory: ${{ github.action_path }}/build # use the build directory | ||
github_token: ${{ inputs.token }} | ||
message: "Update ${{ github.repository }} to ${{ github.sha }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class HelloWorld < Formula | ||
desc "Simple program that outputs 'Hello, World!'" | ||
homepage "https://app.lizardbyte.devm" | ||
url "https://github.com/LizardByte/homebrew-release-action.git" | ||
version "0.0.1" | ||
|
||
def install | ||
# create hello world sh file with echo command | ||
(buildpath/"hello-world").write <<~EOS | ||
#!/bin/sh | ||
echo "Hello, World!" | ||
EOS | ||
|
||
# install the hello-world file to the bin directory | ||
bin.install "hello-world" | ||
end | ||
|
||
test do | ||
system "#{bin}/hello-world" | ||
end | ||
end |