Skip to content

Commit

Permalink
fix :)
Browse files Browse the repository at this point in the history
  • Loading branch information
Siddhant-K-code committed Nov 23, 2023
1 parent 82118b6 commit c94fa55
Show file tree
Hide file tree
Showing 3 changed files with 119 additions and 43 deletions.
116 changes: 73 additions & 43 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,62 +2,92 @@ name: Build 📦 and Release 🚀

on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
workflow_dispatch:

permissions:
contents: read

env:
GO_VERSION: '>=1.21.3'

jobs:
build:
name: Build 📦
test-go-releaser:
name: Test Release Process
if: startsWith(github.ref, 'refs/tags/v') != true
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.17.x]
os: [ubuntu-latest, macos-latest, windows-latest]
arch: [amd64]

steps:
- name: Set up Go
uses: actions/setup-go@v3
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.5.4
with:
go-version: ${{ matrix.go-version }}
fetch-depth: 0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
cache-dependency-path: './go.sum'
check-latest: true
go-version: ${{ env.GO_VERSION }}

- name: Checkout code
uses: actions/checkout@v3
- name: Extract Version from Tag
id: tag_name
run: |
echo "current_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
shell: bash

- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o sheets-to-csv-${{ matrix.os }}-${{ matrix.arch }}
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.5.4
with:
fetch-depth: 0

- name: Upload artifact
uses: actions/upload-artifact@v3
- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
name: sheets-to-csv-${{ matrix.os }}-${{ matrix.arch }}
path: sheets-to-csv-${{ matrix.os }}-${{ matrix.arch }}
cache-dependency-path: './go.sum'
check-latest: true
go-version: ${{ env.GO_VERSION }}

- uses: anchore/sbom-action/download-syft@78fc58e266e87a38d4194b2137a3d4e9bcaf7ca1 # v0.14.3

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
distribution: goreleaser
version: latest
args: release --clean --config .goreleaser.yaml --snapshot --skip-sign --skip-publish --skip-announce

release:
needs: build
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
packages: write # publish a new github release
id-token: write # needed for keyless signing
steps:
- name: Download artifacts
uses: actions/download-artifact@v3

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false

- name: Upload Release Asset 🚀
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./sheets-to-csv-${{ matrix.os }}-${{ matrix.arch }}
asset_name: sheets-to-csv-${{ matrix.os }}-${{ matrix.arch }}
asset_content_type: application/octet-stream
- name: Extract Version from Tag
id: tag_name
run: |
echo "current_version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
shell: bash

- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.5.4
with:
fetch-depth: 0

- name: Set up Go
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
cache-dependency-path: './go.sum'
check-latest: true
go-version: ${{ env.GO_VERSION }}

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0
with:
distribution: goreleaser
version: latest
args: release --clean --config .goreleaser.yaml
env:
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,5 @@

# Go workspace file
go.work

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

# The lines bellow 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

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

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

0 comments on commit c94fa55

Please sign in to comment.