correct release name #2
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 Go Project | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
build: | |
name: Build for ${{ matrix.os }}-${{ matrix.arch }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
include: | |
- os: windows | |
arch: amd64 | |
- os: windows | |
arch: 386 | |
- os: linux | |
arch: arm64 | |
- os: linux | |
arch: amd64 | |
- os: darwin | |
arch: amd64 | |
- os: darwin | |
arch: arm64 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.21' | |
- name: Build | |
env: | |
GOOS: ${{ matrix.os }} | |
GOARCH: ${{ matrix.arch }} | |
run: | | |
output_name="translator-${{ matrix.os }}-${{ matrix.arch }}" | |
if [ "${{ matrix.os }}" = "windows" ]; then | |
output_name="${output_name}.exe" | |
fi | |
go build -v -o ${output_name} . | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: translator-${{ matrix.os }}-${{ matrix.arch }} | |
path: translator-${{ matrix.os }}-${{ matrix.arch }}* | |
create-release: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- name: Get current date | |
id: getdate | |
run: echo "::set-output name=getdate::$(date +'%Y.%m.%d-%H%M')" | |
- uses: actions/checkout@v4 | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ steps.getdate.outputs.getdate }} | |
release_name: Release ${{ steps.getdate.outputs.getdate }} | |
draft: false | |
prerelease: false | |
- uses: actions/download-artifact@v4 | |
- name: Upload Release Assets | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
for artifact in translator-*; do | |
gh release upload v${{ steps.getdate.outputs.getdate }} $artifact/* | |
done |