diff --git a/.github/workflows/goreleaser.yml b/.github/workflows/goreleaser.yml new file mode 100644 index 0000000..f059414 --- /dev/null +++ b/.github/workflows/goreleaser.yml @@ -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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cde0123 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..6d9927b --- /dev/null +++ b/.goreleaser.yaml @@ -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:"