Update develop #40
This file contains hidden or 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: GitHub Build and Package Linux | ||
| on: | ||
| push: | ||
| branches: | ||
| - master | ||
| release: | ||
| types: | ||
| - created | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| ImageName: 'devopcorner/k8s-context' | ||
| AppName: 'k8s-context' | ||
| strategy: | ||
| matrix: | ||
| os: [ubuntu-latest] | ||
| arch: [amd64] | ||
| steps: | ||
| - name: Checkout code at release tag | ||
| uses: actions/checkout@v2 | ||
| with: | ||
| ref: ${{ github.ref }} | ||
| - name: Set up Go environment | ||
| uses: actions/setup-go@v2 | ||
| with: | ||
| go-version: 1.19 | ||
| - name: Install dependencies | ||
| working-directory: src | ||
| run: | | ||
| go mod tidy | ||
| - name: Build binary | ||
| working-directory: src | ||
| run: | | ||
| GOOS=${{ matrix.os }} | ||
| GOARCH=${{ matrix.arch }} | ||
| go build -o ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }} main.go | ||
| - name: Create .deb package | ||
| working-directory: src | ||
| if: matrix.os == 'ubuntu-latest' | ||
| run: | | ||
| sudo apt-get install ruby-dev rubygems build-essential | ||
| sudo gem install fpm | ||
| fpm -s dir -t deb -n ${{ env.AppName }} -v ${{ github.ref_name }} ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }}=/usr/local/bin/ | ||
| - name: Create .zip package for Linux AMD64 | ||
| working-directory: src | ||
| if: matrix.os == 'ubuntu-latest | ||
| run: | | ||
| mkdir -p ${env.AppName}-linux-${{ matrix.arch }} | ||
| cp -r ${{ env.AppName }}-${{ matrix.os }}-${{ matrix.arch }} ${env.AppName}-linux-${{ matrix.arch }}/${env.AppName}} | ||
| zip -r ${env.AppName}-linux-${{ matrix.arch }}.zip ${env.AppName}-linux-${{ matrix.arch }}/ | ||
| - name: Upload packages | ||
| uses: actions/upload-artifact@v2 | ||
| with: | ||
| name: ${{ env.AppName }} | ||
| path: | | ||
| ${{ env.AppName }}-linux-amd64.deb | ||
| ${{ env.AppName }}-linux-amd64.zip | ||