Skip to content

Commit

Permalink
Updated GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
csjones committed Sep 10, 2023
1 parent 1a7392d commit b8d189d
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 47 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/artifact-bundle.yml

This file was deleted.

27 changes: 16 additions & 11 deletions .github/workflows/check-github-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ on:
schedule:
# Daily at 8:20 UTC
- cron: '20 8 * * *'
# Allows you to run this workflow manually from the Actions tab
# Enables manually running this workflow from the Actions tab
workflow_dispatch:

jobs:
check:
name: Check GitHub Release
runs-on: macOS-13
env:
BINARY_NAME: lefthook
BINARY_REPO: evilmartians/lefthook
PLUGIN_REPO: gigabitcoin/template-plugin
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Get lastest binary and plugin versions
run: |
Expand All @@ -21,14 +26,14 @@ jobs:
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
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Print Variables
- name: Update GitHub Env Vars
run: |
echo $PLUGIN_VERSION
echo $BINARY_VERSION
- name: Print Conditionally
run: |
echo $PLUGIN_VERSION
echo $BINARY_VERSION
if: ${{ env.PLUGIN_VERSION == env.BINARY_VERSION }}
# 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 }}
82 changes: 77 additions & 5 deletions .github/workflows/publish-artifact-bundle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,91 @@ name: Publish Artifact Bundle
on:
workflow_call:
inputs:
version:
binary_name:
required: true
type: string
# Allows you to run this workflow manually from the Actions tab
binary_repo:
required: true
type: string
binary_version:
required: true
type: string
plugin_repo:
required: true
type: string

# Enables manually running this workflow from the Actions tab
workflow_dispatch:
inputs:
binary_name:
required: true
type: string
binary_repo:
required: true
type: string
binary_version:
required: true
type: string
plugin_repo:
required: true
type: string

jobs:
publish:
name: Publish Artifact Bundle
runs-on: macOS-13
env:
PLUGIN_VERSION: ${{ inputs.binary_version }}
steps:
- name: Get latest version
- uses: actions/checkout@v4
with:
path: ${{ inputs.binary_name }}
- name: Get latest binaries
run: |
gh release download ${{ inputs.binary_version }} \
-R "${{ inputs.binary_repo }}" \
-p '*MacOS*64' \
-p '*Linux*64' \
-p '*Windows*64.exe' \
-p '*.deb' \
-p '*.rpm' \
-D '${{ inputs.binary_name }}/Resources/template.artifactbundle'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update GitHub Env Vars
run: |
# The example binary includes a leading 'v' in the release version number. We drop it on the next line.
echo "PLUGIN_VERSION=$(echo $PLUGIN_VERSION | cut -c2-)" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${{ inputs.binary_name }}.artifactbundle.zip" >> $GITHUB_ENV
echo "ARTIFACT_PATH=${{ inputs.binary_name }}/Resources/template.artifactbundle" >> $GITHUB_ENV
- name: Set info.json version
run: |
sed -i '' "s/<VERSION>/${{ env.PLUGIN_VERSION }}/g" ${{ env.ARTIFACT_PATH }}/info.json
sed -i '' "s/<TEMPLATE>/${{ inputs.binary_name }}/g" ${{ env.ARTIFACT_PATH }}/info.json
- name: Add executable permissions
run: |
# The example binaries for MacOS need the executable permission added.
chmod +x "${{ env.ARTIFACT_PATH }}/${{ inputs.binary_name }}_${{ env.PLUGIN_VERSION }}_MacOS_arm64"
chmod +x "${{ env.ARTIFACT_PATH }}/${{ inputs.binary_name }}_${{ env.PLUGIN_VERSION }}_MacOS_x86_64"
- name: Zip Artifact Bundle
run: |
zip -9 -r ${{ env.ARTIFACT_NAME }} ${{ env.ARTIFACT_PATH }}
- name: Reset Git Repo
run: |
(cd ${{ inputs.binary_name }} && git reset --hard)
- name: Update Package.swift
run: |
sed -i '' 's/checksum: ".*"/checksum: "${{ hashFiles( env.ARTIFACT_NAME ) }}"/g' ${{ inputs.binary_name }}/Package.swift
sed -i '' -E "s/\/[0-9]+\.[0-9]+\.[0-9]+\//\/1.4.10\//" ${{ inputs.binary_name }}/Package.swift
- name: Push Changes to GitHub
run: |
(cd ${{ inputs.binary_name }} && git commit -am "Updating ${{ inputs.binary_name }} to ${{ env.PLUGIN_VERSION }}" && git push origin)
- name: Create GitHub Release
run: |
echo "$(gh release list -R gigabitcoin/template-plugin -L 1)"
echo $(cd ${{ inputs.binary_name }} && git rev-parse HEAD)
gh release create ${{ env.PLUGIN_VERSION }} \
-R ${{ inputs.plugin_repo }} \
--target $(cd ${{ inputs.binary_name }} && git rev-parse HEAD) \
${{ env.ARTIFACT_NAME }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24 changes: 12 additions & 12 deletions Resources/template.artifactbundle/info.json
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
{
"schemaVersion": "1.0",
"artifacts": {
"template": {
"<TEMPLATE>": {
"type": "executable",
"version": "<VERSION>",
"variants": [
{
"path": "template_<VERSION>_amd64.deb",
"path": "<TEMPLATE>_<VERSION>_amd64.deb",
"supportedTriples": ["x86_64-unknown-linux-deb"]
},
{
"path": "template_<VERSION>_amd64.rpm",
"path": "<TEMPLATE>_<VERSION>_amd64.rpm",
"supportedTriples": ["x86_64-unknown-linux-rpm"]
},
{
"path": "template_<VERSION>_arm64.deb",
"path": "<TEMPLATE>_<VERSION>_arm64.deb",
"supportedTriples": ["arm64-unknown-linux-deb"]
},
{
"path": "template_<VERSION>_arm64.rpm",
"path": "<TEMPLATE>_<VERSION>_arm64.rpm",
"supportedTriples": ["arm64-unknown-linux-rpm"]
},
{
"path": "template_<VERSION>_Linux_arm64",
"path": "<TEMPLATE>_<VERSION>_Linux_arm64",
"supportedTriples": ["arm64-unknown-linux"]
},
{
"path": "template_<VERSION>_Linux_x86_64",
"path": "<TEMPLATE>_<VERSION>_Linux_x86_64",
"supportedTriples": ["x86_64-unknown-linux"]
},
{
"path": "template_<VERSION>_MacOS_arm64",
"supportedTriples": ["arm64-apple-macosx"]
"path": "<TEMPLATE>_<VERSION>_MacOS_arm64",
"supportedTriples": ["arm64-apple-macosx"]
},
{
"path": "template_<VERSION>_MacOS_x86_64",
"path": "<TEMPLATE>_<VERSION>_MacOS_x86_64",
"supportedTriples": ["x86_64-apple-macos"]
},
{
"path": "template_<VERSION>_Windows_arm64.exe",
"path": "<TEMPLATE>_<VERSION>_Windows_arm64.exe",
"supportedTriples": ["arm64-unknown-windows"]
},
{
"path": "template_<VERSION>_Windows_x86_64.exe",
"path": "<TEMPLATE>_<VERSION>_Windows_x86_64.exe",
"supportedTriples": ["x86_64-unknown-windows"]
}
]
Expand Down

0 comments on commit b8d189d

Please sign in to comment.