Add advinst Windows installer #338
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 Publish | |
on: | |
push: | |
branches-ignore: | |
- nightly | |
pull_request: | |
branches: | |
- main | |
release: | |
types: [released] # Prevents double builds on nightly | |
defaults: | |
run: | |
# Use Nix for all of our build commands. | |
# Doing this will automatically run everything in our devShell. | |
shell: nix develop -c bash -e {0} | |
jobs: | |
gomod: | |
name: Validate Go modules | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Tidy up Go modules | |
run: go mod tidy | |
- name: Update gomod2nix.toml | |
run: gomod2nix --outdir nix | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Tidy up Go modules | |
file_pattern: nix/gomod2nix.toml go.mod go.sum | |
generate: | |
name: Run go generate | |
runs-on: ubuntu-latest | |
needs: gomod # avoid pushing at the same time as gomod | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Generate | |
run: go generate ./... | |
- name: Commit changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Run go generate | |
lint: | |
name: Lint | |
needs: [gomod, generate] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Format | |
run: | | |
fail= | |
go list -f '{{ .Dir }}' | while read -r d; do | |
goimports -l "$d" | while read -r f; do | |
fail=1 | |
printf "::error file=%s::%s\n" "$d/$f" "File is not formatted" | |
done | |
done | |
[[ -z "$fail" ]] | |
- name: Vet | |
run: go vet ./... |& workflowify -e -t vet | |
- name: Staticcheck (warnings) | |
run: staticcheck ./... || true |& workflowify -w -t staticcheck | |
- name: Test | |
run: go test -v ./... | |
build-source: | |
name: Build source tarball | |
needs: [gomod, generate] | |
runs-on: ubuntu-latest | |
outputs: | |
name: ${{ steps.build.outputs.name }} | |
directory: ${{ steps.build.outputs.directory }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Build | |
id: build | |
run: | | |
nix build --file ./. lib.mkSource \ | |
--argstr version "$(git-version)" | |
echo name=$(ls result) >> "$GITHUB_OUTPUT" | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.build.outputs.name }} | |
path: result | |
build-linux: | |
name: Build for Linux (via Nix) | |
needs: [gomod, generate] | |
runs-on: ubuntu-latest | |
outputs: | |
name: ${{ steps.build.outputs.name }} | |
versions: ${{ steps.versions.outputs.json }} | |
directory: ${{ steps.build.outputs.directory }} | |
strategy: | |
fail-fast: true | |
matrix: | |
target: | |
- x86_64-linux | |
- aarch64-linux | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Build | |
id: build | |
run: | | |
nix build --file ./. lib.mkPackageCross \ | |
--argstr version "$(git-version)" \ | |
--argstr target "${{ matrix.target }}" | |
echo name=$(ls result) >> "$GITHUB_OUTPUT" | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.build.outputs.name }} | |
path: result | |
build-windows: | |
name: Build for Windows | |
needs: [gomod, generate] | |
runs-on: windows-latest | |
defaults: | |
run: | |
shell: msys2 {0} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Prepare build | |
id: prepare | |
run: | | |
version=$(.github/tools/git-version) | |
name=dissent-windows-amd64-$version | |
cat<<EOF >> "$GITHUB_OUTPUT" | |
version=$version | |
name=$name | |
temp=$(mktemp -d) | |
EOF | |
- name: Build using MSYS2 | |
uses: ./.github/actions/build-msys2-app | |
with: | |
msys-dependencies: | | |
mingw-w64-x86_64-gcc | |
mingw-w64-x86_64-pkg-config | |
mingw-w64-x86_64-gtk4 | |
mingw-w64-x86_64-libadwaita | |
mingw-w64-x86_64-gtksourceview5 | |
mingw-w64-x86_64-gobject-introspection | |
mingw-w64-x86_64-glib2 | |
mingw-w64-x86_64-go | |
out-path: ${{ steps.prepare.outputs.temp }} | |
exe-name: dissent.exe | |
- name: Make MSI installer | |
uses: ./.github/actions/make-advinst-app | |
with: | |
aip-file: nix/dissent-windows.aip | |
exe-directory: ${{ steps.prepare.outputs.temp }} | |
exe-name: dissent.exe | |
app-name: Dissent | |
app-version: ${{ steps.prepare.outputs.version }} | |
icon-file: internal/icons/windows/dissent.ico | |
out-path: result | |
out-name: ${{ steps.prepare.outputs.name }}.msi | |
- name: Upload build artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.prepare.outputs.name }} | |
path: result | |
upload-release: | |
name: Upload artifacts to release | |
needs: [build-source, build-linux, build-windows] | |
environment: Stable release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'release' | |
concurrency: | |
group: release-${{ github.workflow }}-${{ github.ref }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: artifacts | |
- name: Upload artifacts to GitHub Releases | |
uses: diamondburned/action-upload-release@main | |
with: | |
files: artifacts | |
nightly-release: | |
name: Update nightly release | |
needs: [build-source, build-linux, build-windows] | |
environment: Nightly release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
concurrency: | |
group: nightly-${{ github.workflow }}-${{ github.ref }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
- uses: DeterminateSystems/magic-nix-cache-action@main | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
path: /tmp/artifacts | |
- name: Collect built artifacts | |
run: mkdir /tmp/bin && find /tmp/artifacts -type f -exec mv {} /tmp/bin/ \; | |
- name: Generate Nightly release notes | |
id: generate-notes | |
run: | | |
versionJSON=$(nightly-info) | |
version() { jq -r ".$1" <<< "$versionJSON"; } | |
body=$(cat<<EOF | |
This is a nightly release of Dissent. It is built from the latest | |
commit on the `main` branch. | |
**Warning:** This release is not guaranteed to be stable and may | |
contain bugs. Use at your own risk. Please report any issues you | |
encounter as separate GitHub Issues. | |
### Version Information | |
- Dissent: $(version dissent) | |
- Go: $(version go) | |
- GTK: $(version gtk4) | |
- Libadwaita: $(version libadwaita1) | |
EOF) | |
echo "body=$(jq --null-input --arg body "$body" '$body')" >> $GITHUB_OUTPUT | |
env: | |
VERSIONS: ${{ needs.build.outputs.versions }} | |
- name: Update Nightly release | |
uses: andelf/nightly-release@ce2d0a30db8cf9f3920a4237d6a0b874400710c1 | |
with: | |
name: Nightly Release | |
body: ${{ fromJSON(steps.generate-notes.outputs.body) }} | |
tag_name: nightly | |
prerelease: true | |
files: /tmp/bin/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |