build: support pkg managers installation (#87)
closes #71, #84, #86 - AUR - Homebrew - Nix - Debian (.deb) - RPM (.rpm) - Aqua - ASDF This is my first time doing this, so there might be mistakes. If you can't download it through any pkg manager, please leave a comment or open an issue --------- Co-authored-by: use-the-fork <23747916+use-the-fork@users.noreply.github.com>
This commit is contained in:
@@ -1,93 +1,64 @@
|
||||
name: Release
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- 'v*'
|
||||
pull_request:
|
||||
branches: [ '**' ]
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
tags:
|
||||
- "v*"
|
||||
pull_request:
|
||||
branches: ["**"]
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
contents: write
|
||||
|
||||
jobs:
|
||||
quality-and-release:
|
||||
name: Quality & Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
quality-and-release:
|
||||
name: Quality & Release
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24'
|
||||
cache: true
|
||||
|
||||
- name: Tidy
|
||||
run: go mod tidy
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: "1.24"
|
||||
cache: true
|
||||
|
||||
- name: Run Linter
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
version: v2.11.4
|
||||
- name: Tidy
|
||||
run: go mod tidy
|
||||
|
||||
- name: Run Tests
|
||||
run: go test -v ./...
|
||||
- name: Run Linter
|
||||
uses: golangci/golangci-lint-action@v8
|
||||
with:
|
||||
version: v2.11.4
|
||||
|
||||
- name: Build Binaries
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
mkdir -p dist
|
||||
platforms=("linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
|
||||
for platform in "${platforms[@]}"; do
|
||||
os_arch=(${platform//\// })
|
||||
GOOS=${os_arch[0]}
|
||||
GOARCH=${os_arch[1]}
|
||||
output_name="iris"
|
||||
[ "$GOOS" == "windows" ] && output_name="iris.exe"
|
||||
|
||||
echo "Building $GOOS/$GOARCH..."
|
||||
GOOS=$GOOS GOARCH=$GOARCH go build \
|
||||
-ldflags="-s -w -X github.com/versenilvis/iris/root.Version=${{ github.ref_name }}" \
|
||||
-trimpath -o "dist/$output_name" ./cmd/iris
|
||||
|
||||
cd dist
|
||||
tar -czf "iris_${GOOS}_${GOARCH}.tar.gz" "$output_name"
|
||||
rm "$output_name"
|
||||
cd ..
|
||||
done
|
||||
- name: Run Tests
|
||||
run: go test -v ./...
|
||||
|
||||
- name: Prepare Release Notes
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
# Generate standard GitHub release notes
|
||||
GEN_NOTES=$(gh api repos/${{ github.repository }}/releases/generate-notes -f tag_name=${{ github.ref_name }} --jq .body)
|
||||
cat <<EOF > release_notes.md
|
||||
$GEN_NOTES
|
||||
- name: Create vendor tarball
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
run: |
|
||||
go mod vendor
|
||||
tar -czf iris-${GITHUB_REF_NAME#v}-vendor.tar.gz vendor/
|
||||
sha256sum iris-${GITHUB_REF_NAME#v}-vendor.tar.gz > iris-${GITHUB_REF_NAME#v}-vendor.tar.gz.sha256
|
||||
|
||||
## Update
|
||||
\`\`\`bash
|
||||
iris update
|
||||
\`\`\`
|
||||
EOF
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Create GitHub Release
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
name: ${{ github.ref_name }}
|
||||
body_path: release_notes.md
|
||||
files: dist/*.tar.gz
|
||||
generate_release_notes: false
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Run GoReleaser
|
||||
if: startsWith(github.ref, 'refs/tags/v')
|
||||
uses: goreleaser/goreleaser-action@v6
|
||||
with:
|
||||
distribution: goreleaser
|
||||
version: latest
|
||||
args: release --clean
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
AUR_KEY: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
|
||||
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
|
||||
|
||||
Reference in New Issue
Block a user