diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 726e54f..039c177 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v6 with: go-version-file: 'go.mod' - name: Test diff --git a/.github/workflows/publish-github.yml b/.github/workflows/publish-github.yml index 8e58f78..faaebdd 100644 --- a/.github/workflows/publish-github.yml +++ b/.github/workflows/publish-github.yml @@ -12,11 +12,11 @@ jobs: contents: write steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 with: fetch-depth: 0 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v6 with: go-version-file: 'go.mod' - name: Import Apple certificate @@ -38,7 +38,7 @@ jobs: security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" $KEYCHAIN_PATH security list-keychain -d user -s $KEYCHAIN_PATH - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v6 + uses: goreleaser/goreleaser-action@v7 with: version: "~> v2" args: release --clean @@ -61,3 +61,143 @@ jobs: --team-id "$APPLE_TEAM_ID" \ --wait done + + apt: + name: Publish apt repository + runs-on: ubuntu-latest + needs: goreleaser + permissions: + contents: read + steps: + - name: Install dpkg-dev + run: sudo apt-get install -y dpkg-dev + + - name: Checkout apt repo + uses: actions/checkout@v6 + with: + repository: apialerts/apt + token: ${{ secrets.GORELEASER_TOKEN }} + path: apt-repo + + - name: Download .deb packages from release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release download ${{ github.event.release.tag_name }} \ + --pattern "*.deb" \ + --dir debs \ + --repo ${{ github.repository }} + + - name: Import GPG key + run: echo "${{ secrets.APT_GPG_PRIVATE_KEY }}" | base64 -d | gpg --batch --import + + - name: Update apt repository + env: + APT_GPG_PASSPHRASE: ${{ secrets.APT_GPG_PASSPHRASE }} + run: | + mkdir -p apt-repo/pool/main/a/apialerts + cp debs/*.deb apt-repo/pool/main/a/apialerts/ + + cd apt-repo + mkdir -p dists/stable/main/binary-amd64 + mkdir -p dists/stable/main/binary-arm64 + + dpkg-scanpackages --arch amd64 pool/ > dists/stable/main/binary-amd64/Packages + gzip -kf dists/stable/main/binary-amd64/Packages + + dpkg-scanpackages --arch arm64 pool/ > dists/stable/main/binary-arm64/Packages + gzip -kf dists/stable/main/binary-arm64/Packages + + gpg --armor --export > key.gpg + + { + echo "Origin: apialerts" + echo "Label: apialerts" + echo "Suite: stable" + echo "Codename: stable" + echo "Architectures: amd64 arm64" + echo "Components: main" + echo "Description: API Alerts apt repository" + echo "Date: $(date -Ru)" + echo "MD5Sum:" + for f in dists/stable/main/binary-*/Packages*; do + printf " %s %s %s\n" "$(md5sum "$f" | cut -d' ' -f1)" "$(wc -c < "$f")" "${f#dists/stable/}" + done + echo "SHA256:" + for f in dists/stable/main/binary-*/Packages*; do + printf " %s %s %s\n" "$(sha256sum "$f" | cut -d' ' -f1)" "$(wc -c < "$f")" "${f#dists/stable/}" + done + } > dists/stable/Release + + gpg --batch --yes --pinentry-mode loopback --passphrase "$APT_GPG_PASSPHRASE" \ + --clearsign -o dists/stable/InRelease dists/stable/Release + gpg --batch --yes --pinentry-mode loopback --passphrase "$APT_GPG_PASSPHRASE" \ + -abs -o dists/stable/Release.gpg dists/stable/Release + + - name: Push apt repo + run: | + cd apt-repo + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git diff --staged --quiet || git commit -m "Release ${{ github.event.release.tag_name }}" + git push + + rpm: + name: Publish rpm repository + runs-on: ubuntu-latest + needs: goreleaser + permissions: + contents: read + steps: + - name: Install createrepo + run: sudo apt-get install -y createrepo-c rpm + + - name: Checkout rpm repo + uses: actions/checkout@v6 + with: + repository: apialerts/rpm + token: ${{ secrets.GORELEASER_TOKEN }} + path: rpm-repo + + - name: Download .rpm packages from release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh release download ${{ github.event.release.tag_name }} \ + --pattern "*.rpm" \ + --dir rpms \ + --repo ${{ github.repository }} + + - name: Import GPG key + run: echo "${{ secrets.APT_GPG_PRIVATE_KEY }}" | base64 -d | gpg --batch --import + + - name: Update rpm repository + env: + APT_GPG_PASSPHRASE: ${{ secrets.APT_GPG_PASSPHRASE }} + run: | + mkdir -p rpm-repo/packages + cp rpms/*.rpm rpm-repo/packages/ + + gpg --armor --export > rpm-repo/key.gpg + + echo "$APT_GPG_PASSPHRASE" > /tmp/gpg-passphrase + printf '%%_signature gpg\n%%_gpg_name API Alerts \n%%__gpg_sign_cmd %%{__gpg} gpg --batch --no-verbose --no-armor --pinentry-mode loopback --passphrase-file /tmp/gpg-passphrase --no-secmem-warning -u "%%{_gpg_name}" -sbo %%{__signature_filename} %%{__plaintext_filename}\n' > ~/.rpmmacros + for rpm_file in rpm-repo/packages/*.rpm; do + rpmsign --addsign "$rpm_file" + done + rm /tmp/gpg-passphrase + + createrepo_c rpm-repo/ + + gpg --batch --yes --pinentry-mode loopback --passphrase "$APT_GPG_PASSPHRASE" \ + --detach-sign --armor rpm-repo/repodata/repomd.xml + + - name: Push rpm repo + run: | + cd rpm-repo + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add . + git diff --staged --quiet || git commit -m "Release ${{ github.event.release.tag_name }}" + git push diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 13a8e41..881b8c3 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -11,9 +11,9 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Set up Go - uses: actions/setup-go@v4 + uses: actions/setup-go@v6 with: go-version-file: 'go.mod' - name: Test diff --git a/.goreleaser.yaml b/.goreleaser.yaml index fab9c6a..f299f5e 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -33,6 +33,18 @@ archives: checksum: name_template: "checksums.txt" +nfpms: + - id: packages + package_name: apialerts + vendor: apialerts + homepage: https://apialerts.com + maintainer: API Alerts + description: API Alerts CLI — send events from your terminal + license: MIT + formats: + - deb + - rpm + homebrew_casks: - name: apialerts repository: diff --git a/LICENSE b/LICENSE index 59c8785..125b2a9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2024 apialerts +Copyright (c) 2026 apialerts Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index a0e246e..d42be57 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,29 @@ brew tap apialerts/tap brew install --cask apialerts ``` +### apt (Debian / Ubuntu and derivatives) + +```bash +curl -fsSL https://apt.apialerts.com/key.gpg | sudo gpg --dearmor -o /usr/share/keyrings/apialerts.gpg +echo "deb [signed-by=/usr/share/keyrings/apialerts.gpg] https://apt.apialerts.com stable main" | sudo tee /etc/apt/sources.list.d/apialerts.list +sudo apt update && sudo apt install apialerts +``` + +### dnf (Fedora / RHEL / CentOS) + +```bash +sudo rpm --import https://rpm.apialerts.com/key.gpg +sudo tee /etc/yum.repos.d/apialerts.repo <