Upgrade some workflow actions #68
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: Go | |
on: | |
push: | |
branches: [ master ] | |
tags: [ v* ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up Go 1.16+ | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.22' | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- name: Get dependencies | |
run: go get -v -t -d ./... | |
- name: Build (Smoke test) | |
run: CGO_ENABLED=0 go build -v ./... | |
- name: Test | |
run: CGO_ENABLED=0 go test -v ./... | |
- name: Docker Login | |
uses: azure/docker-login@v1 | |
with: | |
login-server: docker.pkg.github.com | |
username: $GITHUB_ACTOR | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build Releases | |
run: | | |
mkdir bin | |
# Platforms that REQUIRE Cgo (because they need libfuse) will be compiled with Xgo. | |
go install github.com/crazy-max/[email protected] | |
xgo --docker-image=ghcr.io/pangbox/pangfiles/xgo:bd83ed073fc2b89295f13375583f7be6592ac8e0 --targets=darwin/amd64 --pkg=cmd/pang --out bin/pang . | |
xgo --docker-image=ghcr.io/pangbox/pangfiles/xgo:bd83ed073fc2b89295f13375583f7be6592ac8e0 --targets=darwin/arm64 --pkg=cmd/pang --out bin/pang . | |
# Other platforms that do not require Cgo (because they prefer Bazilfuse or WinFSP over libfuse) are cross compiled natively. | |
CGO_ENABLED=0 GOOS=freebsd GOARCH=amd64 go build -o bin/pang-freebsd-amd64 ./cmd/pang | |
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/pang-linux-amd64 ./cmd/pang | |
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o bin/pang-windows-amd64.exe ./cmd/pang | |
- name: Upload builds | |
uses: actions/upload-artifact@v2 | |
with: | |
name: bin | |
path: bin/* | |
lint: | |
name: Lint | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Lint | |
uses: golangci/golangci-lint-action@v2 | |
with: | |
version: v1.57.2 | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: startsWith(github.ref, 'refs/tags/') | |
needs: build | |
steps: | |
- name: Download builds | |
uses: actions/download-artifact@v1 | |
with: | |
name: bin | |
- name: Zip builds | |
run: | | |
for i in bin/* | |
do | |
OUT="$PWD/$(basename $i).zip" | |
cd "$(dirname $i)" | |
zip "$OUT" "$(basename $i)" | |
cd - | |
done | |
- name: Get the tag name | |
id: tag | |
run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/} | |
- name: Create Release | |
id: create_release | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: ${{ steps.tag.outputs.VERSION }} | |
release_name: ${{ steps.tag.outputs.VERSION }} | |
draft: true | |
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: pang-macos-amd64.zip, asset_name: pang-macos-amd64.zip, asset_content_type: application/zip } } | |
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: pang-macos-arm64.zip, asset_name: pang-macos-arm64.zip, asset_content_type: application/zip } } | |
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: pang-freebsd-amd64.zip, asset_name: pang-freebsd-amd64.zip, asset_content_type: application/zip } } | |
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: pang-linux-amd64.zip, asset_name: pang-linux-amd64.zip, asset_content_type: application/zip } } | |
- { uses: actions/upload-release-asset@v1, env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }, with: { upload_url: "${{ steps.create_release.outputs.upload_url }}", asset_path: pang-windows-amd64.exe.zip, asset_name: pang-windows-amd64.exe.zip, asset_content_type: application/zip } } |