Release #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: Release | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
paths: | |
- 'main.go' | |
- 'go.mod' | |
env: | |
GO_VERSION: 1.21.6 | |
jobs: | |
build-and-upload-artifacts: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
goos: [linux, darwin, windows] | |
goarch: [amd64, arm64, arm] | |
exclude: | |
- goos: darwin | |
goarch: arm | |
- goos: windows | |
goarch: arm64 | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: ${{ env.GO_VERSION }} | |
- name: Build for ${{ matrix.goos }} ${{ matrix.goarch }} | |
run: | | |
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o hltt_${{ matrix.goos }}_${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} ./... | |
mkdir -p artifacts | |
cp hltt_${{ matrix.goos }}_${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} artifacts/ | |
- name: Upload Artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: hltt_${{ matrix.goos }}_${{ matrix.goarch }} | |
path: artifacts/hltt_${{ matrix.goos }}_${{ matrix.goarch }}${{ matrix.goos == 'windows' && '.exe' || '' }} | |
prepare-and-release: | |
needs: build-and-upload-artifacts | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Generate Tag Name and Create Tag | |
id: generate_tag | |
run: | | |
TAG_NAME=$(date +'%Y%m%d%H%M') | |
echo "Generated tag: $TAG_NAME" | |
echo "::set-output name=tag::$TAG_NAME" | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
git tag -a $TAG_NAME -m "chore(release): $TAG_NAME" | |
git push origin $TAG_NAME | |
- uses: actions/download-artifact@v2 | |
with: | |
path: artifacts | |
- name: Create Release | |
id: create_release | |
uses: actions/create-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
with: | |
tag_name: ${{ steps.generate_tag.outputs.tag }} | |
release_name: Release ${{ steps.generate_tag.outputs.tag }} | |
draft: false | |
prerelease: false | |
- name: check something | |
run: | | |
ls -l | |
ls -l artifacts | |
zip -r artifacts.zip artifacts | |
ls -l | |
- name: Upload Artifacts to Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: | | |
artifacts/**/hltt_* | |
fail_on_unmatched_files: true | |
tag_name: ${{ steps.generate_tag.outputs.tag }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} |