Bump actions/download-artifact from 2.0.5 to 4.1.7 in /.github/workflows #29
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: Go | |
on: | |
push: | |
paths: | |
- '**.go' | |
- '.github/workflows/**' | |
pull_request: | |
paths: | |
- '**.go' | |
- '.github/workflows/**' | |
jobs: | |
linter: | |
name: "golang-linter" | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: 1.17 | |
- uses: actions/checkout@v2 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v2 | |
with: | |
version: v1.43 | |
skip-go-installation: true | |
test: | |
name: Unit Test | |
needs: [linter] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
steps: | |
- uses: actions/checkout@v2 | |
- name: before cache | |
run: | | |
mkdir -p ~/go/pkg/mod | |
- uses: actions/[email protected] | |
id: cache-go | |
with: | |
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }} | |
path: ~/go/pkg/mod | |
restore-keys: | | |
go-${{ matrix.os }}- | |
- name: Setup GoLang | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ^1.17 | |
- name: Get Dependencies | |
if: steps.cache-go.outputs.cache-hit != 'true' | |
run: go get -v -t -d ./... | |
- name: Test | |
run: | | |
go test -v ./... | |
build: | |
name: Build release binary | |
runs-on: ${{ matrix.os }} | |
needs: [linter, test] | |
if: contains(github.ref, 'tags/v') | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macOS-latest] | |
steps: | |
- uses: actions/[email protected] | |
- name: before cache | |
run: | | |
mkdir -p ~/go/pkg/mod | |
- uses: actions/[email protected] | |
id: cache-go | |
with: | |
key: ${{ matrix.os }}-go-${{ hashFiles('**/go.sum') }} | |
path: ~/go/pkg/mod | |
restore-keys: | | |
go-${{ matrix.os }}- | |
- name: Setup GoLang | |
uses: actions/[email protected] | |
with: | |
go-version: ^1.17 | |
- name: Get Dependencies | |
if: steps.cache-go.outputs.cache-hit != 'true' | |
run: go get -v -t -d ./... | |
- name: vars | |
id: vars | |
shell: bash | |
run: | | |
echo ::set-output name=os::"$(echo ${{ matrix.os }} | sed 's/-latest//g;s/ubuntu/linux/g')" | |
echo ::set-output name=version::${TAG_REF_NAME##*/v} | |
env: | |
TAG_REF_NAME: ${{ github.ref }} | |
- name: Build | |
run: | | |
mkdir ./${{ steps.vars.outputs.os }} | |
go build -v -o ${{ steps.vars.outputs.os }}/go-cdx | |
- name: Create completion script | |
shell: bash | |
working-directory: ${{ steps.vars.outputs.os }} | |
run: | | |
mkdir -p $HOME/.config/go-cdx | |
touch $HOME/.config/go-cdx/go-cdx.yaml | |
[[ "${{ matrix.os }}" != "windows-latest" ]] && { | |
./go-cdx --completion zsh - > ./cdx-completion.zsh | |
./go-cdx --completion bash - > ./cdx-completion.bash | |
./go-cdx --completion fish - > ./cdx-completion.fish | |
} | |
./go-cdx --completion PowerShell - > ./cdx-completion.ps1 | |
- name: Upload artifact | |
uses: actions/[email protected] | |
with: | |
name: ${{ steps.vars.outputs.os }} | |
path: ./${{ steps.vars.outputs.os }} | |
create-release: | |
needs: [linter, test, build] | |
if: contains(github.ref, 'tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: vars | |
id: vars | |
run: | | |
echo ::set-output name=version::${TAG_REF_NAME##*/v} | |
env: | |
TAG_REF_NAME: ${{ github.ref }} | |
- name: Create Release | |
uses: actions/[email protected] | |
id: create_release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.vars.outputs.version }} | |
release_name: Release ${{ steps.vars.outputs.version }} | |
draft: false | |
prerelease: false | |
- name: Output release url | |
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt | |
- name: Save Release URL File for publish | |
uses: actions/[email protected] | |
with: | |
name: release_url | |
path: release_url.txt | |
upload-release: | |
runs-on: ubuntu-latest | |
if: contains(github.ref, 'tags/v') | |
needs: [linter, create-release, test, build] | |
strategy: | |
matrix: | |
os: [linux, windows, macOS] | |
steps: | |
- uses: actions/[email protected] | |
with: | |
name: ${{ matrix.os }} | |
path: ${{ matrix.os }} | |
- uses: actions/[email protected] | |
with: | |
name: release_url | |
- name: Get Release Info | |
id: get_release_info | |
shell: bash | |
run: | | |
echo ::set-output name=file_name::${REPOSITORY_NAME##*/}-${TAG_REF_NAME##*/v} | |
echo ::set-output name=upload_url::"$(cat release_url.txt)" | |
echo ::set-output name=version::${TAG_REF_NAME##*/v} | |
env: | |
TAG_REF_NAME: ${{ github.ref }} | |
REPOSITORY_NAME: ${{ github.repository }} | |
- name: Create Zip | |
shell: bash | |
run: | | |
zip -r ${{ matrix.os }} ${{ matrix.os }} | |
- name: Upload assets to GitHub Release | |
id: upload-release-asset | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ steps.get_release_info.outputs.upload_url }} | |
asset_path: ./${{ matrix.os }}.zip | |
asset_name: ${{ steps.get_release_info.outputs.file_name }}-${{ matrix.os }}.zip | |
asset_content_type: application/zip |