Skip to content

ci: auto-bump patch version o push to main #7

ci: auto-bump patch version o push to main

ci: auto-bump patch version o push to main #7

Workflow file for this run

name: Release
on:
push:
branches: ["main"]
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Bump version and create tag
run: |
LATEST_TAG=$(git tag --sort=-v:refname | grep '^v' | head -1)
if [ -z "$LATEST_TAG" ]; then
LATEST_TAG="v0.0.0"
fi
IFS='.' read -r MAJOR MINOR PATCH <<< "${LATEST_TAG#v}"
NEW_VERSION="${MAJOR}.${MINOR}.$((PATCH + 1))"
echo "VERSION=${NEW_VERSION}" >> $GITHUB_ENV
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag "v${NEW_VERSION}"
git push origin "v${NEW_VERSION}"
- name: Build binaries
run: |
mkdir -p dist bin
GOOS=linux GOARCH=amd64 go build -ldflags "-s -w -X main.version=$VERSION" -o dist/duckflux-linux-amd64 ./cmd/duckflux
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X main.version=$VERSION" -o dist/duckflux-darwin-amd64 ./cmd/duckflux
GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X main.version=$VERSION" -o dist/duckflux-darwin-arm64 ./cmd/duckflux
- name: Install nfpm
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@latest
- name: Build .deb
run: |
cp dist/duckflux-linux-amd64 bin/duckflux
nfpm pkg --packager deb --target dist/duckflux_${VERSION}_amd64.deb
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
dist/duckflux-linux-amd64
dist/duckflux-darwin-amd64
dist/duckflux-darwin-arm64
dist/duckflux_${{ env.VERSION }}_amd64.deb
- name: Update apt-repo
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
run: |
gh auth setup-git
gh repo clone duckflux/apt-repo /tmp/apt-repo
echo "$GPG_PRIVATE_KEY" | gpg --batch --import
cp "dist/duckflux_${VERSION}_amd64.deb" /tmp/apt-repo/pool/main/
cd /tmp/apt-repo
dpkg-scanpackages --multiversion pool/main > dists/stable/main/binary-amd64/Packages
gzip -k -f dists/stable/main/binary-amd64/Packages
cat > /tmp/release.conf <<EOF
APT::FTPArchive::Release::Origin "duckflux";
APT::FTPArchive::Release::Label "duckflux";
APT::FTPArchive::Release::Suite "stable";
APT::FTPArchive::Release::Codename "stable";
APT::FTPArchive::Release::Architectures "amd64";
APT::FTPArchive::Release::Components "main";
EOF
apt-ftparchive -c /tmp/release.conf release dists/stable > dists/stable/Release
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback \
--clearsign -o dists/stable/InRelease dists/stable/Release
echo "$GPG_PASSPHRASE" | gpg --batch --yes --passphrase-fd 0 --pinentry-mode loopback \
-abs -o dists/stable/Release.gpg dists/stable/Release
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "release: duckflux v${VERSION}"
git push
npm install --global wrangler
wrangler deploy
- name: Update homebrew-tap
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
gh auth setup-git
gh repo clone duckflux/homebrew-tap /tmp/homebrew-tap
TARBALL_URL="https://github.com/duckflux/runner/archive/refs/tags/v${VERSION}.tar.gz"
SHA256=$(curl -sL "$TARBALL_URL" | sha256sum | awk '{print $1}')
sed -i "s|url \".*\"|url \"${TARBALL_URL}\"|" /tmp/homebrew-tap/Formula/runner.rb
sed -i "s|sha256 \".*\"|sha256 \"${SHA256}\"|" /tmp/homebrew-tap/Formula/runner.rb
git -C /tmp/homebrew-tap config user.name "github-actions[bot]"
git -C /tmp/homebrew-tap config user.email "github-actions[bot]@users.noreply.github.com"
git -C /tmp/homebrew-tap add Formula/runner.rb
git -C /tmp/homebrew-tap commit -m "release: duckflux v${VERSION}"
git -C /tmp/homebrew-tap push