Skip to content

Bump actions/download-artifact from 2.0.5 to 4.1.7 in /.github/workflows #29

Bump actions/download-artifact from 2.0.5 to 4.1.7 in /.github/workflows

Bump actions/download-artifact from 2.0.5 to 4.1.7 in /.github/workflows #29

Workflow file for this run

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/cache@v2.1.2
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/checkout@v2.3.3
- name: before cache
run: |
mkdir -p ~/go/pkg/mod
- uses: actions/cache@v2.1.2
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@v2.1.3
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/upload-artifact@v2.2.0
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/create-release@v1.1.4
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/upload-artifact@v2.2.0
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/download-artifact@v4.1.7
with:
name: ${{ matrix.os }}
path: ${{ matrix.os }}
- uses: actions/download-artifact@v4.1.7
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/upload-release-asset@v1.0.2
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