Skip to content

Still dont have the syntax right. Iterating the heredoc. #13

Still dont have the syntax right. Iterating the heredoc.

Still dont have the syntax right. Iterating the heredoc. #13

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
steps:
- name: 'Get source code artifact and binary for this version'
run: |
mkdir templ-downloads
cd templ-downloads
curl -LO https://github.com/${{ github.repository }}/archive/refs/tags/${{ needs.build-and-release-tag.outputs.version_tag }}.tar.gz
#The binary is used to hydrate the formula later.
curl -LO https://github.com/${{ github.repository }}/releases/download/${{ needs.build-and-release-tag.outputs.version_tag }}/templ-linux
chmod +x templ-linux
ls -ltr
- name: 'Generate sha256 sum'
id: generate-sha256
run: |
SHA256=$(shasum -a 256 "templ-downloads/templ-${{ needs.build-and-release-tag.outputs.version_tag }}.tar.gz" | awk '{print $1}')
echo "templ sha256 is ${SHA256}"
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
- name: 'Download homebrew-templ'
uses: actions/checkout@v3
with:
repository: 'PlayTechnique/homebrew-templ'
ssh-key: '${{ secrets.HOMEBREWTEMPLSSHKEY }}'
- name: 'Prepare a template file'
run: |
cat > template.templ <<EOF
class Templ < Formula

Check failure on line 140 in .github/workflows/go_release.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/go_release.yaml

Invalid workflow file

You have an error in your yaml syntax on line 140
desc "A templating tool that downloads git repositories."
homepage "https://github.com/PlayTechnique/templ"
url "https://github.com/PlayTechnique/templ/archive/refs/tags/{{ .TAG }}.tar.gz"
sha256 "{{ .SHASUM }}"
license ""
depends_on "go" => :build
def install
# ENV.deparallelize # if your formula fails when building in parallel
system "go", "build", *std_go_args(ldflags: "-s -w")
end
test do
# `test do` will create, run in and delete a temporary directory.
#
# This test will fail and we won't accept that! For Homebrew/homebrew-core
# this will need to be a test that verifies the functionality of the
# software. Run the test with `brew test templ`. Options passed
# to `brew install` such as `--HEAD` also need to be provided to `brew test`.
#
# The installed folder is not in the path, so use the entire path to any
# executables being tested: `system "#{bin}/program", "do", "something"`.
system "false"
end
end
EOF
chmod +x ./templ-downloads/templ
cat template.templ | ./templ-downloads/templ TAG=${{ needs.build-and-release-tag.outputs.version_tag }} SHASUM=${{ steps.generate-sha256.outputs.sha256 }} > Formula/templ.rb
- name: "Add new repo file"
run: |
git add Formula/templ.rb
git commit -m "Auto-Updater from templ: updating for ${{ needs.build-and-release-tag.outputs.version_tag }}"
git push