Skip to content

Commit

Permalink
Add goreleaser
Browse files Browse the repository at this point in the history
  • Loading branch information
marxjohnson committed Sep 12, 2024
1 parent 440183a commit 7cb3d42
Show file tree
Hide file tree
Showing 3 changed files with 158 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go Releaser

on:
push:
branches: [ "goreleaser" ]
tags:
- '*'

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'

- uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: build --clean --snapshot --single-target --output dist/powerline-go-moodle

- name: Upload artifact
uses: actions/upload-artifact@v4
with:
# Artifact name
name: testbuild
# A file, directory or wildcard pattern that describes what to upload
path: dist/powerline-go-moodle

test:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v4
with:
name: testbuild
- name: Test
run: |
chmod +x powerline-go-moodle
git clone https://github.com/moodle/moodle
cd moodle
git checkout v4.4.1
../powerline-go-moodle | jq -e '.[]["name"] == "moodle"' || exit 1
../powerline-go-moodle | jq -e '.[]["content"] == "M4.4.1"' || exit 1
git checkout v4.3.4
../powerline-go-moodle | jq -e '.[]["name"] == "moodle"' || exit 1
../powerline-go-moodle | jq -e '.[]["content"] == "M4.3.4"' || exit 1
release:
runs-on: ubuntu-latest
needs: test
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAP_STORE_LOGIN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

dist/
82 changes: 82 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# This is an example .goreleaser.yml file with some sensible defaults.
# Make sure to check the documentation at https://goreleaser.com

# The lines below are called `modelines`. See `:help modeline`
# Feel free to remove those if you don't want/need to use them.
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
# vim: set ts=2 sw=2 tw=0 fo=cnqoj

version: 2

before:
hooks:
# You may remove this if you don't use go modules.
- go mod tidy
# you may remove this if you don't need go generate
- go generate ./...

builds:
- env:
- CGO_ENABLED=0
goos:
- linux
- windows
- darwin

archives:
- format: tar.gz
# this name template makes the OS and Arch compatible with the results of `uname`.
name_template: >-
{{ .ProjectName }}_
{{- title .Os }}_
{{- if eq .Arch "amd64" }}x86_64
{{- else if eq .Arch "386" }}i386
{{- else }}{{ .Arch }}{{ end }}
{{- if .Arm }}v{{ .Arm }}{{ end }}
# use zip for windows archives
format_overrides:
- goos: windows
format: zip

snapcrafts:
- name: powerline-go-moodle
summary: A Moodle plugin for powerline-go
description: |
This plugin adds a segment to powerline-go which displays the [Moodle](https://moodle.org) version the current directory belongs to.
Once installed, add `moodle` to the `-modules` argument when you configure `powerline-go` for your shell.
For example, for Bash, your `.bashrc` should contain something like:
```bash
function _update_ps1() {
PS1="$($HOME/go/bin/powerline-go \
-error $? \
-jobs $(jobs -p | wc -l) \
-hostname-only-if-ssh \
-modules 'aws,cwd,git,root,exit,moodle')"
}
```
base: core22

confinement: strict

publish: true

grade: devel

license: GPL-3.0-or-later

apps:
powerline-go-moodle:
command: bin/powerline-go-moodle
plugs:
- home
- removable-media

changelog:
sort: asc
filters:
exclude:
- "^docs:"
- "^test:"

0 comments on commit 7cb3d42

Please sign in to comment.