Skip to content

update actionlint

update actionlint #16

Workflow file for this run

---
name: CI
"on":
push:
branches:
- "main"
tags:
- "v*.*.*"
pull_request:
branches:
- "main"
permissions:
contents: read
jobs:
meta:
name: Derive Build Metadata
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Derive version string
id: bin_version
run: echo "bin_version=$(./.version.sh)" >> "$GITHUB_OUTPUT"
- name: bin_version
run: "echo bin_version: ${{ steps.bin_version.outputs.bin_version }}"
- name: Check if this is a running version tag update
id: running_version_tag
run: |
if [ -z "${{ github.event.ref }}" ]; then
echo "is_running_version_tag_update=false" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+$ ]]; then
echo "is_running_version_tag_update=true" >> "$GITHUB_OUTPUT"
elif [[ "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+$ ]]; then
echo "is_running_version_tag_update=true" >> "$GITHUB_OUTPUT"
else
echo "is_running_version_tag_update=false" >> "$GITHUB_OUTPUT"
fi
- name: is_running_version_tag
run: "echo is_running_version_tag_update: ${{ steps.running_version_tag.outputs.is_running_version_tag_update }}"
outputs:
# nb. homebrew-releaser assumes the program name is == the repository name
bin_name: ${{ github.event.repository.name }}
bin_version: ${{ steps.bin_version.outputs.bin_version }}
brewtap_owner: ${{ github.repository_owner }}
brewtap_name: oss
brewtap_formula_dir: formula
is_prerelease: >-
${{
steps.running_version_tag.outputs.is_running_version_tag_update != 'true' &&
startsWith(github.ref, 'refs/tags/v') &&
(contains(github.ref, '-alpha.')
|| contains(github.ref, '-beta.')
|| contains(github.ref, '-rc.'))
}}
is_release: >-
${{
steps.running_version_tag.outputs.is_running_version_tag_update != 'true' &&
startsWith(github.ref, 'refs/tags/v') &&
!(contains(github.ref, '-alpha.')
|| contains(github.ref, '-beta.')
|| contains(github.ref, '-rc.'))
}}
is_pull_request: ${{ github.event_name == 'pull_request' }}
is_running_version_tag_update: ${{ steps.running_version_tag.outputs.is_running_version_tag_update }}
lint:
name: Lint & Format
runs-on: ubuntu-latest
permissions:
contents: write
checks: write
issues: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Generate build dependencies
run: make deps
- name: golangci-lint
uses: golangci/golangci-lint-action@v6.0.1
with:
version: latest
- name: ShellCheck
uses: ludeeus/action-shellcheck@2.0.0
- name: Install Prettier
run: npm install -g prettier
- name: Prettier
run: prettier --check .
- name: Actionlint
uses: raven-actions/actionlint@v2
- name: Setup shfmt
uses: mfinelli/setup-shfmt@v3.0.1
- name: shfmt
run: shfmt -d .
binaries:
name: Binaries
needs: [lint, meta]
if: needs.meta.outputs.is_running_version_tag_update != 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version-file: "go.mod"
- name: Go version
run: go version
- name: Build binaries
run: make build
- name: Prepare release artifacts
working-directory: out/
run: |
mkdir ./gh-release
find . -name '${{ needs.meta.outputs.bin_name }}-*' -executable -type f -maxdepth 1 -print0 | xargs -0 -I {} tar --transform='flags=r;s|.*|${{ needs.meta.outputs.bin_name }}|' -czvf ./gh-release/{}.tar.gz {}
- name: Upload binaries & packages
uses: actions/upload-artifact@v4
with:
name: ${{ needs.meta.outputs.bin_name }} Binary Artifacts
path: out/gh-release/*
release:
name: GitHub (Pre)Release
needs: [meta, binaries]
if: >-
needs.meta.outputs.is_release == 'true' ||
needs.meta.outputs.is_prerelease == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download binaries & packages
uses: actions/download-artifact@v4
with:
name: ${{ needs.meta.outputs.bin_name }} Binary Artifacts
path: out
- name: List artifacts
working-directory: out
run: ls -R
- name: Create GitHub release
uses: softprops/action-gh-release@v1
with:
files: out/${{ needs.meta.outputs.bin_name }}-*
prerelease: ${{ needs.meta.outputs.is_prerelease == 'true' }}
fail_on_unmatched_files: true
generate_release_notes: true
tags:
name: Update Release Tags
needs: [meta, release]
if: needs.meta.outputs.is_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update running major/minor version tags
uses: sersoft-gmbh/running-release-tags-action@v3
with:
fail-on-non-semver-tag: true
create-release: false
update-full-release: false
homebrew:
name: Update Homebrew Tap
needs: [meta, binaries, release]
if: needs.meta.outputs.is_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Release to ${{ needs.meta.outputs.brewtap_owner }}/${{ needs.meta.outputs.brewtap_name }} tap
uses: Justintime50/homebrew-releaser@v1
with:
homebrew_owner: ${{ needs.meta.outputs.brewtap_owner }}
homebrew_tap: homebrew-${{ needs.meta.outputs.brewtap_name }}
formula_folder: ${{ needs.meta.outputs.brewtap_formula_dir }}
update_readme_table: true
github_token: ${{ secrets.HOMEBREW_RELEASER_PAT }}
commit_owner: homebrew-releaser-bot
commit_email: homebrew-releaser-bot@users.noreply.github.com
target_darwin_amd64: true
target_darwin_arm64: true
target_linux_amd64: false
target_linux_arm64: false
version: v${{ needs.meta.outputs.bin_version }}
install: 'bin.install "${{ needs.meta.outputs.bin_name }}"'
test: 'assert_match("${{ needs.meta.outputs.bin_version }}", shell_output("#{bin}/${{ needs.meta.outputs.bin_name }} version"))'
ntfy:
name: Ntfy
if: ${{ !cancelled() }}
runs-on: ubuntu-latest
needs: [meta, lint, binaries, tags, release, homebrew]
steps:
- name: Send success notification
uses: niniyas/ntfy-action@master
if: ${{ !contains(needs.*.result, 'failure') && (needs.meta.outputs.is_release == 'true' || needs.meta.outputs.is_prerelease == 'true') }}
with:
url: "https://ntfy.cdzombak.net"
topic: "gha-builds"
priority: 3
headers: '{"authorization": "Bearer ${{ secrets.NTFY_TOKEN }}"}'
tags: white_check_mark
title: ${{ github.event.repository.name }} ${{ needs.meta.outputs.bin_version }} available
details: ${{ github.event.repository.name }} version ${{ needs.meta.outputs.bin_version }} is now available.
- name: Send failure notification
uses: niniyas/ntfy-action@master
if: ${{ contains(needs.*.result, 'failure') }}
with:
url: "https://ntfy.cdzombak.net"
topic: "gha-builds"
priority: 3
headers: '{"authorization": "Bearer ${{ secrets.NTFY_TOKEN }}"}'
tags: no_entry
title: ${{ github.event.repository.name }} ${{ needs.meta.outputs.bin_version }} build failed
details: Build failed for ${{ github.event.repository.name }} version ${{ needs.meta.outputs.bin_version }}.