Adding Auto Deploy Workflows for Nightly and Tagged builds #5
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: Test | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
permissions: | |
contents: write | |
packages: write | |
issues: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
- name: Install dependencies | |
run: go mod download | |
- name: Run tests | |
run: go test -v . | |
goreleaser: | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: stable | |
- name: Install Deps | |
run: | | |
sudo apt-get install tree git-extras -y | |
- name: Release config | |
run: | | |
cat << EOF > /tmp/goreleaser-github.yaml | |
project_name: tz | |
version: 2 | |
builds: | |
- env: [CGO_ENABLED=0] | |
goos: | |
- linux | |
- windows | |
- darwin | |
- freebsd | |
- openbsd | |
goarch: | |
- 386 | |
- amd64 | |
- arm | |
- arm64 | |
nfpms: | |
- | |
maintainer: Arnaud Berthomier <oz@cyprio.net> | |
bindir: /usr/local/bin | |
description: A time zone helper | |
homepage: https://github.com/oz/tz | |
license: GPL-3 | |
formats: | |
- deb | |
- rpm | |
- apk | |
- termux.deb | |
- archlinux | |
- ipk | |
EOF | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v6 | |
with: | |
distribution: goreleaser | |
# 'latest', 'nightly', or a semver | |
version: "~> v2" | |
args: release --clean --verbose --snapshot --config /tmp/goreleaser-github.yaml | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: List Dist | |
run: | | |
tree dist | |
- name: Add changelog | |
run: | | |
git-changelog -a -x -t >> dist/CHANGELOG.md | |
- name: Generate artifact name | |
id: artifact_name | |
run: | | |
REPO_NAME=${GITHUB_REPOSITORY##*/} | |
SHORT_SHA=${GITHUB_SHA::7} | |
ARTIFACT_NAME="${REPO_NAME}-${GITHUB_REF_NAME}-${SHORT_SHA}" | |
echo "name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT | |
- name: Upload Dist | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ steps.artifact_name.outputs.name }} | |
path: dist/* | |
retention-days: 14 | |