fix default --output when --template supplied #106
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: build | |
defaults: | |
run: | |
shell: bash | |
on: | |
push: | |
jobs: | |
# https://github.com/golangci/golangci-lint-action | |
lint: | |
name: lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/setup-go@v3 | |
with: | |
go-version: 1.17 | |
- uses: actions/checkout@v3 | |
- name: golangci-lint | |
uses: golangci/golangci-lint-action@v3 | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.17' | |
- run: go version | |
- run: go test ./... | |
version: | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: test | |
outputs: | |
release-version: ${{ steps.parse.outputs.release-version }} | |
runs-on: ubuntu-latest | |
steps: | |
- id: parse | |
env: | |
GITHUB_REF: ${{ github.ref }} | |
name: Parse version from tag ${{ github.ref }} | |
run: | | |
if [[ "${GITHUB_REF}" =~ ^refs/tags/(v[0-9]+\.[0-9]+\.[0-9]+)$ ]]; then | |
echo "::set-output name=release-version::${BASH_REMATCH[1]}" | |
fi | |
release: | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
RELEASE_DIR: .github-release | |
RELEASE_VERSION: ${{ needs.version.outputs.release-version }} | |
if: needs.version.outputs.release-version | |
needs: version | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.17' | |
- id: build | |
name: Build release artifacts version ${{ env.RELEASE_VERSION }} | |
run: | | |
mkdir -p "${RELEASE_DIR}" | |
for PLATFORM in windows linux darwin; do | |
EXTENSION="" | |
if [[ "${PLATFORM}" == 'windows' ]]; then | |
EXTENSION=".exe" | |
fi | |
export GOOS="${PLATFORM}" | |
export GOARCH=amd64 | |
export CGO_ENABLED=0 | |
OUT_FILE="${RELEASE_DIR}/clconf-${PLATFORM}${EXTENSION}" | |
echo "Creating ${OUT_FILE} (${RELEASE_VERSION})" | |
go build \ | |
-ldflags "-X github.com/pastdev/clconf/v3/pkg/cmd.version=$RELEASE_VERSION" \ | |
-o "${OUT_FILE}" \ | |
./cmd/clconf | |
echo "::set-output name=${PLATFORM}-artifact::${OUT_FILE}" | |
done | |
ls -lrt "${RELEASE_DIR}" | |
- id: create-release | |
name: Create release ${{ env.RELEASE_VERSION }} | |
uses: actions/create-release@v1 | |
with: | |
tag_name: ${{ env.RELEASE_VERSION }} | |
release_name: ${{ env.RELEASE_VERSION }} | |
draft: false | |
prerelease: false | |
- if: ${{ steps.build.outputs.darwin-artifact }} | |
name: Upload darwin release ${{ env.RELEASE_VERSION }} | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: ${{ steps.build.outputs.darwin-artifact }} | |
asset_name: clconf-darwin | |
asset_content_type: application/octet-stream | |
- if: ${{ steps.build.outputs.linux-artifact }} | |
name: Upload linux release ${{ env.RELEASE_VERSION }} | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: ${{ steps.build.outputs.linux-artifact }} | |
asset_name: clconf-linux | |
asset_content_type: application/octet-stream | |
- if: ${{ steps.build.outputs.windows-artifact }} | |
name: Upload windows release ${{ env.RELEASE_VERSION }} | |
uses: actions/upload-release-asset@v1 | |
with: | |
upload_url: ${{ steps.create-release.outputs.upload_url }} | |
asset_path: ${{ steps.build.outputs.windows-artifact }} | |
asset_name: clconf-windows.exe | |
asset_content_type: application/octet-stream |