diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..fe2a5c1 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,23 @@ +name: Build + +# on: +# push: +# branches: [ main ] +# pull_request: +# branches: [ main ] + +jobs: + macOS: + name: Test + runs-on: macOS-13 + steps: + - uses: actions/checkout@v3 + - name: List available plugins in macOS + run: swift package plugin template + + Linux: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Build Docker image + run: docker build . diff --git a/.github/workflows/check-github-release.yml b/.github/workflows/check-github-release.yml new file mode 100644 index 0000000..a977862 --- /dev/null +++ b/.github/workflows/check-github-release.yml @@ -0,0 +1,63 @@ +name: Check GitHub Release + +# on: +# schedule: +# Daily at 8:20 UTC and 20:20 UTC +# - cron: '20 8,20 * * *' +# # Enables manually running this workflow from the Actions tab +# workflow_dispatch: + +jobs: + check: + name: Check GitHub Release + runs-on: ubuntu-latest + env: + BINARY_NAME: lefthook + BINARY_REPO: evilmartians/lefthook + PLUGIN_REPO: 21-DOT-DEV/swift-plugin-template + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SEMANTIC_VERSIONING_REGEX: (v?[0-9]+\.[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 }} + steps: + - name: Get current plugin version + id: one + run: | + PLUGIN_RELEASE=$(gh release list -R ${{ github.repository }} -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 "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 ${{ 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 }} \ No newline at end of file diff --git a/.github/workflows/publish-artifact-bundle.yml b/.github/workflows/publish-artifact-bundle.yml new file mode 100644 index 0000000..c4ee181 --- /dev/null +++ b/.github/workflows/publish-artifact-bundle.yml @@ -0,0 +1,92 @@ +name: Publish Artifact Bundle + +# on: +# workflow_call: +# 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 + +# # 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 }} + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + steps: + - 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' + - 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 + echo "ESCAPED_PLUGIN_REPO=$(echo "${{ inputs.plugin_repo }}" | sed 's/\//\\\//g')" >> $GITHUB_ENV + - name: Set info.json version + run: | + sed -i '' "s//${{ env.PLUGIN_VERSION }}/g" ${{ env.ARTIFACT_PATH }}/info.json + sed -i '' "s/