Skip to content

Add tag condition

Add tag condition #21

Workflow file for this run

name: Go Releaser
on:
push:
branches: [ "goreleaser" ]
jobs:
build:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.tag.outputs.tag }}
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true
- name: Check for tag
id: tag
run: |
tag=$(git tag --points-at ${{ github.sha }} | grep '^v' | head -1)
echo "tag = ${tag}"
echo "tag=${tag}" >> $GITHUB_OUTPUT
- 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:
- build
- test
if: ${{ startsWith(needs.build.outputs.tag, 'v') }}
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.20'
- name: install snapcraft
run: sudo snap install snapcraft --classic
- 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 }}
- name: Upload snpacraft log
if: always()
uses: actions/upload-artifact@v4
with:
# Artifact name
name: snapcraft-log
# A file, directory or wildcard pattern that describes what to upload
path: /home/runner/.local/state/snapcraft/log