go #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
# https://docs.github.com/en/actions/learn-github-actions/contexts | |
name: release | |
permissions: | |
contents: write | |
on: | |
push: | |
branches: [ "main" ] | |
jobs: | |
build-push: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: version | |
run: | | |
VERSION=$( date '+%y%m%d.%H%M.0' ) | |
echo "VERSION:$VERSION" | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- uses: actions/setup-go@v4 | |
with: | |
go-version: '^1.21.1' | |
- name: go build | |
run: GOOS=linux GOARCH=amd64 go build -o ${{ github.event.repository.name }}.linux.amd64 -trimpath -ldflags '-X main.Version='$VERSION | |
- name: gzip | |
run: gzip -k ${{ github.event.repository.name }}.linux.amd64 | |
- name: list files | |
run: ls -l -a | |
- name: release notes | |
run: echo 'curl -sSL https://github.com/shoce/${{ github.event.repository.name }}/releases/latest/download/${{ github.event.repository.name }}.linux.amd64.gz | gunzip | put /bin/${{ github.event.repository.name }} 755' >release.notes..text | |
- name: gh release | |
shell: bash | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: gh release create $VERSION ${{ github.event.repository.name }}.linux.amd64.gz --notes-file release.notes..text | |