Skip to content

Commit

Permalink
Upgrade go and dependencies and gh actions (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
dee-kryvenko authored Jul 24, 2024
1 parent fc1b469 commit 1ca3102
Show file tree
Hide file tree
Showing 5 changed files with 2,486 additions and 153 deletions.
122 changes: 122 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
name: Go Build
run-name: "${{ inputs.releaseVersion }}"

on:
pull_request:
branches:
- main
push:
branches:
- main
workflow_dispatch:
inputs:
releaseVersion:
type: string
description: Version of the image to push
required: true

permissions:
contents: write
packages: write
checks: write
statuses: write

jobs:
build:
name: Build
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, darwin, windows]
arch: [386, amd64, arm64]
exclude:
- os: darwin
arch: 386
- os: windows
arch: arm64
steps:
- name: Set version
run: |
echo "RELEASE_VERSION=dev" >> $GITHUB_ENV
- name: Set release version
if: github.event_name == 'workflow_dispatch'
run: |
echo "RELEASE_VERSION=${{ github.event.inputs.releaseVersion }}" >> $GITHUB_ENV
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.22'

- name: Checkout Code
uses: actions/checkout@v4

- name: Add Windows Exe File Extension
if: matrix.os == 'windows'
run: echo "FILE_EXTENSION=.exe" >> $GITHUB_ENV

- name: Go Build
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
run: |
go build \
-o build/github-apps-trampoline-${{ matrix.os }}-${{ matrix.arch }}${{ env.FILE_EXTENSION }}
if [ "${{ matrix.os }}" = "linux" ]; then
go build \
-trimpath \
-ldflags='-extldflags=-static -w -s' \
-tags osusergo,netgo \
-o build/github-apps-trampoline-${{ matrix.os }}-static-${{ matrix.arch }}${{ env.FILE_EXTENSION }}
fi
- name: Upload Artifact
uses: actions/upload-artifact@v4
if: github.event_name == 'workflow_dispatch'
with:
name: github-apps-trampoline
path: build/github-apps-trampoline-${{ matrix.os }}-${{ matrix.arch }}${{ env.FILE_EXTENSION }}

- name: Upload Static Artifact
uses: actions/upload-artifact@v4
if: matrix.os == 'linux' && github.event_name == 'workflow_dispatch'
with:
name: github-apps-trampoline-static
path: build/github-apps-trampoline-${{ matrix.os }}-static-${{ matrix.arch }}${{ env.FILE_EXTENSION }}

release:
name: Release
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'workflow_dispatch'
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: github-apps-trampoline
path: github-apps-trampoline

- name: Download Static Artifacts
uses: actions/download-artifact@v4
with:
name: github-apps-trampoline-static
path: github-apps-trampoline-static

- name: Generate SHA256SUMS
run: |
pwd && ls -la && cd github-apps-trampoline* && sha256sum * > SHA256SUMS
- name: Create Release
uses: ncipollo/release-action@v1
with:
name: ${{ github.event.inputs.releaseVersion }}
generateReleaseNotes: true
commit: ${{ github.sha }}
tag: ${{ github.event.inputs.releaseVersion }}
makeLatest: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67 changes: 0 additions & 67 deletions .github/workflows/release.yml

This file was deleted.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
# vendor/

github-apps-trampoline
build
16 changes: 6 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ module github.com/plumber-cd/github-apps-trampoline
go 1.16

require (
github.com/fsnotify/fsnotify v1.5.1 // indirect
github.com/golang-jwt/jwt/v4 v4.0.0
github.com/mitchellh/mapstructure v1.4.2 // indirect
github.com/pelletier/go-toml v1.9.4 // indirect
github.com/spf13/cast v1.4.1 // indirect
github.com/spf13/cobra v1.2.1
github.com/spf13/viper v1.8.1
golang.org/x/sys v0.0.0-20210917161153-d61c044b1678 // indirect
golang.org/x/text v0.3.7 // indirect
gopkg.in/ini.v1 v1.63.2 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0
github.com/sagikazarmark/locafero v0.6.0 // indirect
github.com/spf13/cobra v1.8.1
github.com/spf13/viper v1.19.0
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect
)
Loading

0 comments on commit 1ca3102

Please sign in to comment.