Skip to content

identify the workflow to run, gwyn #32

identify the workflow to run, gwyn

identify the workflow to run, gwyn #32

Workflow file for this run

name: "Compile and Release on Tag Push"
on:
push:
tags:
- '*'
workflow_dispatch:
jobs:
build-and-release-tag:
if: github.repository == 'playtechnique/templ'
runs-on: ubuntu-22.04
env:
OUTPUT_BINARY: templ
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: "checkout"
uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF }}
fetch-depth: 0
- name: 'Get Previous tag'
id: previoustag
uses: "WyriHaximus/github-action-get-previous-tag@v1"
- name: "checkout again at tag version"
uses: actions/checkout@v3
with:
ref: ${{ steps.previoustag.outputs.tag }}
- name: show we understand previoustag
run: |
echo "<${{ steps.previoustag.outputs.tag }}>"
- name: 'Check if release already exists'
id: check_release
run: |
RELEASE_URL=$(curl -sH "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ steps.previoustag.outputs.tag }}" \
| jq -r ".url" )
if [[ "$RELEASE_URL" != "null" ]]; then
echo "Release already exists. Skipping..."
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: "compile binary"
if: steps.check_release.outputs.exists == 'false'
run: |
GOOS=linux go build -o ${{ env.OUTPUT_BINARY }}-linux
GOOS=darwin GOARCH=amd64 go build -o ${{ env.OUTPUT_BINARY }}-mac-amd64
GOOS=darwin GOARCH=arm64 go build -o ${{ env.OUTPUT_BINARY }}-mac-arm64
GOOS=windows GOARCH=amd64 go build -o ${{ env.OUTPUT_BINARY }}-win-amd64
- name: Release
if: steps.check_release.outputs.exists == 'false'
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ steps.previoustag.outputs.tag }}
release_name: Release ${{ steps.previoustag.outputs.tag }}
- name: Upload linux
if: steps.check_release.outputs.exists == 'false'
id: upload-linux-asset
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-linux
asset_name: ${{ env.OUTPUT_BINARY }}-linux
asset_content_type: binary
- name: Upload macos amd64
if: steps.check_release.outputs.exists == 'false'
id: upload-macos-asset-amd64
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-mac-amd64
asset_name: ${{ env.OUTPUT_BINARY }}-mac-amd64
asset_content_type: binary
- name: Upload macos arm64
if: steps.check_release.outputs.exists == 'false'
id: upload-macos-asset-arm64
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-mac-arm64
asset_name: ${{ env.OUTPUT_BINARY }}-mac-arm64
asset_content_type: binary
- name: Upload windows arm64
if: steps.check_release.outputs.exists == 'false'
id: upload-windows-asset-arm64
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.OUTPUT_BINARY }}-win-amd64
asset_name: ${{ env.OUTPUT_BINARY }}-win-amd64
asset_content_type: binary
outputs:
version_tag: ${{ steps.previoustag.outputs.tag }}
release-homebrew:
runs-on: ubuntu-22.04
needs: build-and-release-tag
env:
SOURCE_CODE_URL: https://github.com/${{ github.repository }}/archive/refs/tags/${{ needs.build-and-release-tag.outputs.version_tag }}.tar.gz
steps:
- name: 'Get source code artifact and binary for this version'
run: |
mkdir templ-downloads
cd templ-downloads
curl -LO ${{ env.SOURCE_CODE_URL }}
- name: 'Generate sha256 sum'
id: generate-sha256
run: |
SHA256=$(shasum -a 256 "templ-downloads/${{ needs.build-and-release-tag.outputs.version_tag }}.tar.gz" | awk '{print $1}')
echo "templ sha256 is ${SHA256}"
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: 'Trigger homebrew-templ action'
run: |
export SHA_VALUE=${{ steps.generate-sha256.outputs.sha256 }}
export URL_VALUE=${{ env.SOURCE_CODE_URL }}
export TAG_VERSION=${{ needs.build-and-release-tag.outputs.version_tag }}
export LICENSE="BSD-3-Clause"
echo "SHA VALUE: ${SHA_VALUE}"
echo "URL VALUE: ${URL_VALUE}"
echo "TAG VERSION: ${TAG_VERSION}"
echo ${{ secrets.HOMEBREW_TEMPL_PAT }} | gh auth login -h github.com --with-tokendxbfnklmDXCFRGVB KLO,
gh workflow run update-formula.yaml -R PlayTechnique/homebrew-templ -f SHA256=${SHA_VALUE} -f DOWNLOAD_URL=${URL_VALUE} -f VERSION=${TAG_VERSION}