Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Auto Deploy Workflows for Nightly and Tagged builds #74

Merged
merged 5 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 0 additions & 27 deletions .github/workflows/go.yml

This file was deleted.

118 changes: 118 additions & 0 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
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 <[email protected]>
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

142 changes: 119 additions & 23 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,29 +1,125 @@
name: Build Go Binaries for new releases
name: Release

on:
release:
types: [created]
push:
# run only against tags
tags:
- "*"

permissions:
contents: write
packages: write
issues: write

jobs:
releases-matrix:
name: Build Go Binaries
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 ./... -coverprofile=./cover.out -covermode=atomic -coverpkg=./...

goreleaser:
needs:
- test
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin, openbsd, netbsd, freebsd]
goarch: ["amd64", "arm", "arm64"]
exclude:
- goarch: arm
goos: darwin
- goarch: arm64
goos: windows
steps:
- uses: actions/checkout@v4
- uses: wangyoucao577/go-release-action@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
sha256sum: true
md5sum: false
extra_files: COPYING
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: stable

- 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 <[email protected]>
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

release:
draft: false # If set to true, will not auto-publish the release.
replace_existing_draft: true
replace_existing_artifacts: true
target_commitish: "{{ .Commit }}"
prerelease: auto

make_latest: true
mode: replace
include_meta: true

EOF

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
# 'latest', 'nightly', or a semver
version: "~> v2"
args: release --clean --verbose --config /tmp/goreleaser-github.yaml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: List Dist
run: |
sudo apt-get install tree -y
tree dist

- name: Upload .deb artifact x86
uses: actions/upload-artifact@v3
with:
name: deb-package
path: dist/*amd64.deb
- name: Upload .deb artifact ARM
uses: actions/upload-artifact@v3
with:
name: deb-package-arm
path: dist/*arm64.deb
- name: Upload .rpm artifact x86
uses: actions/upload-artifact@v3
with:
name: rpm-package
path: dist/*amd64.rpm
- name: Upload .apk artifact x86
uses: actions/upload-artifact@v3
with:
name: apk-package
path: dist/*amd64.apk
Loading