Skip to content

Release

Release #20

Workflow file for this run

name: Release
on:
release:
types: [created]
permissions:
contents: write
id-token: write
jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
- name: Update version
run: |
DATE=$(date -u +"%Y-%m-%d")
sed -i "s/const Version = \".*\"/const Version = \"${GITHUB_REF_NAME}\"/" pkg/version/version.go
sed -i "s/const Revision = \".*\"/const Revision = \"${GITHUB_SHA}\"/" pkg/version/version.go
sed -i "s/const Date = \".*\"/const Date = \"${DATE}\"/" pkg/version/version.go
sed -i "s/Standards-Version: \*.*\"/Standards-Version: \"${GITHUB_REF_NAME}\"/" build/debian/control
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git add pkg/version/version.go
git commit -m "Update version to ${GITHUB_REF_NAME}"
git push origin main
goreleaser:
needs: update-version
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '>=1.20.0'
- name: Install Cosign
uses: sigstore/cosign-installer@v3.7.0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: v2.4.7
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
COSIGN_EXPERIMENTAL: 1
publish-aur:
needs: [goreleaser]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate PKGBUILD
run: |
# Remove 'v' prefix from version number for pkgver
VERSION="${GITHUB_REF_NAME}"
VERSION_NO_V=$(echo "$VERSION" | sed 's/^v//')
echo "Building package for version: $VERSION_NO_V"
cat > PKGBUILD << EOF
# Maintainer: Chris Watson <cawatson1993@gmail.com>
pkgname=goshot-bin
pkgver=${VERSION_NO_V}
pkgrel=1
pkgdesc="A powerful CLI tool and library for creating beautiful code screenshots with customizable window chrome, syntax highlighting, and backgrounds"
arch=('x86_64' 'aarch64')
url="https://github.com/watzon/goshot"
license=('MIT')
optdepends=(
'wl-clipboard: clipboard support for Wayland'
'xclip: clipboard support for X11'
)
provides=('goshot')
conflicts=('goshot')
source_x86_64=("goshot_Linux_x86_64.tar.gz::https://github.com/watzon/goshot/releases/download/v\${pkgver}/goshot_Linux_x86_64.tar.gz")
source_aarch64=("goshot_Linux_arm64.tar.gz::https://github.com/watzon/goshot/releases/download/v\${pkgver}/goshot_Linux_arm64.tar.gz")
sha256sums_x86_64=('SKIP')
sha256sums_aarch64=('SKIP')
package() {
cd "\$srcdir"
install -Dm755 goshot "\$pkgdir/usr/bin/goshot"
install -Dm644 LICENSE "\$pkgdir/usr/share/licenses/\$pkgname/LICENSE"
}
EOF
- name: Publish AUR package
uses: KSXGitHub/github-actions-deploy-aur@v3.0.1
with:
pkgname: goshot-bin
pkgbuild: ./PKGBUILD
commit_username: ${{ secrets.AUR_USERNAME }}
commit_email: ${{ secrets.AUR_EMAIL }}
ssh_private_key: ${{ secrets.AUR_SSH_PRIVATE_KEY }}
commit_message: "Update to version ${GITHUB_REF#refs/tags/v}"
ppa:
needs: goreleaser
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Import GPG
uses: crazy-max/ghaction-import-gpg@v3.1.0
with:
gpg-private-key: ${{ secrets.LAUNCHPAD_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.LAUNCHPAD_GPG_PASSPHRASE }}
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y devscripts debhelper-compat dput
- name: Prepare package
env:
DEBEMAIL: "cawatson1993@gmail.com"
DEBFULLNAME: "Chris Watson"
run: |
VERSION=${GITHUB_REF#refs/tags/v}
# Copy debian directory to the right place and create orig tarball
cp -r build/debian debian
mv .github ..
tar cfv ../goshot_${VERSION}.orig.tar .
xz -9 ../goshot_${VERSION}.orig.tar
mv ../.github .
# Update changelog
dch -v ${VERSION}-1 --distribution jammy "New upstream release"
- name: Build source package
run: debuild -S -sa -d
- name: Upload to PPA
run: |
cat > ~/.dput.cf << EOF
[ppa]
fqdn = ppa.launchpad.net
method = ftp
incoming = ~watzon/ubuntu/goshot
login = anonymous
allow_unsigned_uploads = no
EOF
dput ppa:watzon/goshot ../goshot_*_source.changes