Skip to content

Commit

Permalink
Plugin Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
csjones committed Sep 11, 2023
1 parent 6c6c7f8 commit 8ff56a1
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v3
- name: List available plugins in macOS
run: swift package plugin template
run: swift package plugin lefthook

Linux:
runs-on: ubuntu-latest
Expand Down
60 changes: 43 additions & 17 deletions .github/workflows/check-github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,30 +10,56 @@ on:
jobs:
check:
name: Check GitHub Release
runs-on: macOS-13
runs-on: ubuntu-latest
env:
BINARY_NAME: lefthook
BINARY_REPO: evilmartians/lefthook
PLUGIN_REPO: gigabitcoin/template-plugin
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SEMANTIC_VERSIONING_REGEX: (v[0-9]+\.[0-9]+\.[0-9]+)|(0\.[0-9]+\.[0-9]+)
outputs:
BINARY_NAME: ${{ env.BINARY_NAME }}
BINARY_REPO: ${{ env.BINARY_REPO }}
BINARY_VERSION: ${{ steps.two.outputs.BINARY_VERSION }}
PLUGIN_VERSION: ${{ steps.one.outputs.PLUGIN_VERSION }}
TRIMMED_BINARY_VERSION: ${{ steps.three.outputs.TRIMMED_BINARY_VERSION }}
steps:
- name: Get lastest binary and plugin versions
- name: Get current plugin version
id: one
run: |
SEMANTIC_VERSIONING_REGEX="(v[0-9]+\.[0-9]+\.[0-9]+)|(0\.[0-9]+\.[0-9]+)"
PLUGIN_RELEASE=$(gh release list -R ${{ github.repository }} -L 1)
PLUGIN_RELEASE=$(gh release list -R gigabitcoin/template-plugin -L 1)
BINARY_RELEASE=$(gh release list -R evilmartians/lefthook -L 1)
echo "PLUGIN_VERSION=$(echo $PLUGIN_RELEASE | grep -oE "${{ env.SEMANTIC_VERSIONING_REGEX }}" | head -n1)" >> $GITHUB_OUTPUT
- name: Get current binary version
id: two
run: |
BINARY_RELEASE=$(gh release list -R ${{ env.BINARY_REPO }} -L 1)
echo "PLUGIN_VERSION=$(echo $PLUGIN_RELEASE | grep -oE $SEMANTIC_VERSIONING_REGEX | head -n1)" >> $GITHUB_ENV
echo "BINARY_VERSION=$(echo $BINARY_RELEASE | grep -oE $SEMANTIC_VERSIONING_REGEX | head -n1)" >> $GITHUB_ENV
- name: Update GitHub Env Vars
echo "BINARY_VERSION=$(echo $BINARY_RELEASE | grep -oE "${{ env.SEMANTIC_VERSIONING_REGEX }}" | head -n1)" >> $GITHUB_OUTPUT
- name: Get trimmed binary version
id: three
run: |
# The example binary includes a leading 'v' in the release version number. We drop it on the next line.
echo "TRIMMED_BINARY_VERSION=$(echo $BINARY_VERSION | cut -c2-)" >> $GITHUB_ENV
- uses: ./.github/workflows/publish-artifact-bundle.yml
with:
binary_name: ${{ env.BINARY_NAME }}
binary_repo: ${{ env.BINARY_REPO }}
binary_version: ${{ env.BINARY_RELEASE }}
plugin_repo: ${{ env.PLUGIN_REPO }}
if: ${{ env.PLUGIN_VERSION == env.TRIMMED_BINARY_VERSION }}
echo "TRIMMED_BINARY_VERSION=$(echo ${{ steps.two.outputs.BINARY_VERSION }} | cut -c2-)" >> $GITHUB_OUTPUT
debug:
name: Debug Outputs
needs: check
runs-on: ubuntu-latest
steps:
- name: Print outputs from check job
run: |
echo "${{ needs.check.outputs.BINARY_NAME }}"
echo "${{ needs.check.outputs.BINARY_REPO }}"
echo "${{ needs.check.outputs.BINARY_VERSION }}"
echo "${{ github.repository }}"
echo "${{ needs.check.outputs.PLUGIN_VERSION }}"
echo "${{ needs.check.outputs.TRIMMED_BINARY_VERSION }}"
trigger:
name: Trigger Artifact Publish
needs: check
uses: ./.github/workflows/publish-artifact-bundle.yml
with:
binary_name: ${{ needs.check.outputs.BINARY_NAME }}
binary_repo: ${{ needs.check.outputs.BINARY_REPO }}
binary_version: ${{ needs.check.outputs.BINARY_VERSION }}
plugin_repo: ${{ github.repository }}
if: ${{ needs.check.outputs.PLUGIN_VERSION != needs.check.outputs.TRIMMED_BINARY_VERSION }}
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ ADD . /Linux
WORKDIR /Linux

# List available plugins in Linux
RUN swift package plugin template
RUN swift package plugin lefthook
20 changes: 10 additions & 10 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,31 @@
import PackageDescription

let package = Package(
name: "template",
name: "lefthook",
products: [
.plugin(
name: "template",
name: "lefthook",
targets: [
"TemplatePlugin"
"LefthookPlugin"
]
)
],
dependencies: [],
targets: [
.plugin(
name: "TemplatePlugin",
name: "LefthookPlugin",
capability: .command(
intent: .custom(
verb: "template",
description: "Execute commands defined by template."
verb: "lefthook",
description: "Execute commands defined in lefthook.yml."
)
),
dependencies: ["template"]
dependencies: ["lefthook"]
),
// .binaryTarget(name: "template", path: "template.artifactbundle.zip"),
// .binaryTarget(name: "lefthook", path: "lefthook.artifactbundle.zip"),
.binaryTarget(
name: "template",
url: "https://github.com/GigaBitcoin/template-plugin/releases/download/0.0.1/template.artifactbundle.zip",
name: "lefthook",
url: "https://github.com/csjones/lefthook-plugin/releases/download/0.0.1/lefthook.artifactbundle.zip",
checksum: "42e1e7a4f7d7586ec6d13b3e03cce5612ac237244cc3cb1e6de7c49416d04520"
),
],
Expand Down

0 comments on commit 8ff56a1

Please sign in to comment.