fix lockfile #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 and Release | |
on: | |
push: | |
tags: | |
- "v*" # Trigger on version tags | |
branches: | |
- master | |
# Allows manual trigger | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build and Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repo | |
uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Install Dependencies | |
run: pnpm install | |
- name: Set build env | |
run: | | |
echo "VITE_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
echo "VITE_APP_VERSION=$(jq -r .version ./package.json)" >> $GITHUB_ENV | |
- name: Build | |
run: pnpm build | |
- name: Redirect 404 to Index for SPA | |
run: cp dist/index.html dist/404.html | |
- name: Copy app to exe/web | |
run: cp -r dist/* exe/web | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.23" | |
- name: Set Version | |
run: | | |
if [ "${{ github.event_name }}" == "push" && startsWith(github.ref, 'refs/tags/') ]; then | |
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV | |
else | |
echo "VERSION=dev-$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
fi | |
- name: Create bin directory | |
run: mkdir -p exe/bin | |
- name: Build for Windows | |
run: | | |
cd exe && GOOS=windows GOARCH=amd64 go build -ldflags="-X 'main.Version=${VERSION}'" -o bin/myapp-windows-amd64.exe | |
- name: Build for macOS | |
run: | | |
cd exe && GOOS=darwin GOARCH=amd64 go build -ldflags="-X 'main.Version=${VERSION}'" -o bin/myapp-darwin-amd64 | |
- name: Build for Linux | |
run: | | |
cd exe && GOOS=linux GOARCH=amd64 go build -ldflags="-X 'main.Version=${VERSION}'" -o bin/myapp-linux-amd64 | |
# Add executable permissions to macOS and Linux binaries | |
- name: Make binaries executable | |
run: | | |
chmod +x exe/bin/myapp-darwin-amd64 | |
chmod +x exe/bin/myapp-linux-amd64 | |
# Upload as workflow artifacts | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: binaries | |
path: exe/bin/* | |
# Create Release | |
# - name: Create Release | |
# if: startsWith(github.ref, 'refs/tags/') | |
# id: create_release | |
# uses: softprops/action-gh-release@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# with: | |
# files: | | |
# bin/myapp-windows-amd64.exe | |
# bin/myapp-darwin-amd64 | |
# bin/myapp-linux-amd64 | |
# draft: false | |
# prerelease: false | |
# generate_release_notes: true |