simplify instance checker #284
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-release | |
on: | |
push: | |
branches: | |
- unstable | |
- main | |
tags: | |
- v* | |
jobs: | |
package: | |
strategy: | |
matrix: | |
platform: [macos-latest, ubuntu-latest] | |
runs-on: ${{ matrix.platform }} | |
outputs: | |
version: ${{ steps.version.outputs.version }} | |
revision: ${{ steps.version.outputs.revision }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# we need the whole thing so we can count commits. | |
fetch-depth: '0' | |
- name: Install Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version-file: 'go.mod' | |
- name: setup node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Installs Wails | |
run: go install github.com/wailsapp/wails/v2/cmd/wails@latest | |
- name: Inject Version Info | |
id: version | |
run: | | |
VERSION=$(git describe --abbrev=0 --tags $(git rev-list --tags --max-count=1) | tr -d v) | |
[ "$VERSION" != "" ] || VERSION=0.0.0 | |
REVISION=$(git rev-list --count --all || echo 0) | |
COMMIT=$(echo "${{github.sha}}" | head -c 7) | |
jq ".info.productVersion = \"${VERSION}\"" wails.json > wails.json.new | |
mv wails.json.new wails.json | |
jq ".version = \"${VERSION}\"" frontend/package.json > frontend/package.json.new | |
mv frontend/package.json.new frontend/package.json | |
VERSION_LDFLAGS="-X \"golift.io/version.Branch=${{github.ref_name}} (${COMMIT})\" \ | |
-X \"golift.io/version.BuildDate=$(date -u +%Y-%m-%dT%H:%M:00Z)\" \ | |
-X \"golift.io/version.BuildUser=$(whoami || echo "unknown")\" \ | |
-X \"golift.io/version.Revision=${REVISION}\" \ | |
-X \"golift.io/version.Version=${VERSION}\"" | |
echo "VERSION_LDFLAGS=${VERSION_LDFLAGS}" >> $GITHUB_ENV | |
echo "VERSION=${VERSION}" >> $GITHUB_ENV | |
echo "REVISION=${REVISION}" >> $GITHUB_ENV | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "revision=${REVISION}" >> $GITHUB_OUTPUT | |
- name: Build macOS | |
if: runner.os == 'macOS' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/unstable') | |
env: | |
APPLE_SIGNING_KEY: ${{ secrets.APPLE_SIGNING_KEY }} | |
AC_USERNAME: ${{ secrets.AC_USERNAME }} | |
AC_PASSWORD: ${{ secrets.AC_PASSWORD }} | |
AC_PROVIDER: ${{ secrets.AC_PROVIDER }} | |
run: | | |
wails build -m -trimpath -platform darwin/universal -webview2 embed -ldflags='${{ env.VERSION_LDFLAGS }}' | |
brew install Bearer/tap/gon | |
build/darwin/makedmg.sh | |
- name: Build Linux AMD64 | |
if: runner.os == 'Linux' | |
shell: bash | |
run: | | |
sudo apt update | |
sudo apt install -y libgtk-3-0 libwebkit2gtk-4.0-dev nsis osslsigncode rpm fakeroot zip debsigs gnupg jq | |
sudo gem install --no-document fpm | |
go mod vendor | |
wails build -trimpath -platform linux/amd64 -webview2 embed -o toolbarr.amd64 -ldflags='${{ env.VERSION_LDFLAGS }}' | |
# This one sucked to figure out, and it's slow, but it works! | |
# - name: Build Linux ARM | |
# if: runner.os == 'Linux' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/unstable') | |
# uses: pguyot/arm-runner-action@v2 | |
# with: | |
# base_image: https://cdimage.ubuntu.com/releases/22.10/release/ubuntu-22.10-preinstalled-desktop-arm64+raspi.img.xz | |
# bind_mount_repository: true | |
# image_additional_mb: 900 | |
# commands: | | |
# echo "update_initramfs=no" >> /etc/initramfs-tools/update-initramfs.conf | |
# apt update | |
# apt install -y libgtk-3-0 libwebkit2gtk-4.0-dev gcc wget | |
# wget https://go.dev/dl/go1.20.2.linux-arm64.tar.gz | |
# tar -C /usr/local -xzf go1.20.2.linux-arm64.tar.gz | |
# PATH=$PATH:/usr/local/go/bin | |
# GOFLAGS="-trimpath -mod=readonly" GOARCH=arm64 \ | |
# go build -o build/bin/toolbarr.arm64 -ldflags='${{ env.VERSION_LDFLAGS }}' . | |
- name: Build Windows | |
if: runner.os == 'Linux' | |
env: | |
EXE_SIGNING_KEY: ${{ secrets.EXE_SIGNING_KEY }} | |
EXE_SIGNING_KEY_PASSWORD: ${{ secrets.EXE_SIGNING_KEY_PASSWORD }} | |
run: | | |
wails build -s -m -trimpath -platform windows/amd64 -nsis -webview2 embed -o Toolbarr.amd64.exe -ldflags='${{ env.VERSION_LDFLAGS }}' | |
wails build -s -m -trimpath -platform windows/arm64 -nsis -webview2 embed -o Toolbarr.arm64.exe -ldflags='${{ env.VERSION_LDFLAGS }}' | |
for FILE in build/bin/*.a??64.exe; do zip -9j "${FILE%.*}.zip" "${FILE}"; done | |
- name: Package Linux Binaries | |
if: runner.os == 'Linux' && (startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/unstable') | |
env: | |
KEYID: B93DD66EF98E54E2EAE025BA0166AD34ABC5A57C | |
GPG_SIGNING_KEY: ${{ secrets.GPG_SIGNING_KEY }} | |
PACKAGE_ARGS: >- | |
--name toolbarr | |
--deb-no-default-config-files | |
--rpm-os linux | |
--iteration ${{ env.REVISION }} | |
--license MIT | |
--url https://github.com/notifiarr/toolbarr | |
--vendor "Notifiarr <notifiarr.com>" | |
--maintainer "Go Lift <[email protected]>" | |
--description "The starr of the show." | |
run: | | |
echo "${GPG_SIGNING_KEY}" | gpg --import - | |
mkdir -p pkg/deb/{amd64,arm64}/usr/bin pkg/rpm/{x86_64,aarch64}/usr/bin | |
cp build/bin/toolbarr.amd64 pkg/rpm/x86_64/usr/bin/toolbarr | |
cp build/bin/toolbarr.amd64 pkg/deb/amd64/usr/bin/toolbarr | |
# cp build/bin/toolbarr.arm64 pkg/rpm/aarch64/usr/bin/toolbarr | |
# cp build/bin/toolbarr.arm64 pkg/deb/arm64/usr/bin/toolbarr | |
RPMVERSION=$(echo ${{ env.VERSION }} | tr -- - _) | |
eval fpm -s dir -t rpm ${PACKAGE_ARGS} -a x86_64 -v ${RPMVERSION} -C pkg/rpm/x86_64 | |
eval fpm -s dir -t deb ${PACKAGE_ARGS} -a amd64 -v ${{ env.VERSION }} -C pkg/deb/amd64 | |
# eval fpm -s dir -t rpm ${PACKAGE_ARGS} -a aarch64 -v ${RPMVERSION} -C pkg/rpm/aarch64 | |
# eval fpm -s dir -t deb ${PACKAGE_ARGS} -a arm64 -v ${{ env.VERSION }} -C pkg/deb/arm64 | |
rpmsign --key-id="${KEYID}" --resign toolbarr-${RPMVERSION}-${REVISION}.x86_64.rpm | |
debsigs --default-key="${KEYID}" --sign=origin toolbarr_${{ env.VERSION }}-${REVISION}_amd64.deb | |
# rpmsign --key-id="${KEYID}" --resign toolbarr-${RPMVERSION}-${REVISION}.aarch64.rpm | |
# debsigs --default-key="${KEYID}" --sign=origin toolbarr_${{ env.VERSION }}-${REVISION}_arm64.deb | |
mv *.deb *.rpm build/bin | |
gzip -9 build/bin/toolbarr.*64 | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: toolbarr-${{ matrix.platform }} | |
path: build/bin/* | |
deploy-unstable-packagecloud: | |
# description: "Uploads pre-built RPM and DEB packages to packagecloud.io/golift" | |
if: github.ref == 'refs/heads/unstable' | |
needs: package | |
name: Deploy Unstable PackageCloud | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download release files | |
uses: actions/download-artifact@v4 | |
with: | |
name: toolbarr-ubuntu-latest | |
- uses: golift/upload-packagecloud@v1 | |
with: | |
userrepo: golift/unstable | |
apitoken: ${{ secrets.PACKAGECLOUD_TOKEN }} | |
packages: . | |
rpmdists: el/6 | |
debdists: ubuntu/focal | |
deploy-unstable-unstable: | |
# description: "Uploads pre-built binaries to unstable.golift.io." | |
if: startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/unstable' | |
strategy: | |
matrix: | |
files: [toolbarr-macos-latest, toolbarr-ubuntu-latest] | |
needs: package | |
name: Deploy Unstable | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Download files: ${{ matrix.files }}" | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.files }} | |
- name: Upload files to unstable.golift.io | |
run: >- | |
for file in *.{zip,dmg,gz,installer.exe}; do | |
[ -f "$file" ] || continue; | |
echo "Uploading: ${file}"; | |
curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=toolbarr" -F "file=@${file}"; | |
echo '{"version":"${{needs.package.outputs.version}}","revision":${{needs.package.outputs.revision}},"size":'$(stat --printf="%s" ${file})'}' >> ${file}.txt | |
curl -sSH "X-API-KEY: ${{ secrets.UNSTABLE_UPLOAD_KEY }}" "https://unstable.golift.io/upload.php?folder=toolbarr" -F "file=@${file}.txt"; | |
done | |
deploy-release-packagecloud: | |
# description: "Uploads pre-built RPM and DEB packages to packagecloud.io/golift" | |
if: startsWith(github.ref, 'refs/tags/v') | |
needs: package | |
name: Deploy Release PackageCloud | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download release files | |
uses: actions/download-artifact@v4 | |
with: | |
name: toolbarr-ubuntu-latest | |
- uses: golift/upload-packagecloud@v1 | |
with: | |
userrepo: golift/pkgs | |
apitoken: ${{ secrets.PACKAGECLOUD_TOKEN }} | |
packages: . | |
rpmdists: el/6 | |
debdists: ubuntu/focal | |
deploy-github-release: | |
# description: uploads all the built release assets to the GitHub Release. | |
if: startsWith(github.ref, 'refs/tags/v') | |
permissions: | |
contents: write | |
needs: package | |
strategy: | |
matrix: | |
files: [toolbarr-macos-latest, toolbarr-ubuntu-latest] | |
name: Deploy GitHub Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download ${{ matrix.files }} Files | |
uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.files }} | |
- name: Publish ${{ matrix.files }} artifacts to github | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: | | |
*.rpm | |
*.deb | |
*.zip | |
*.dmg | |
*.gz | |
*.txt | |
*.installer.exe |