Skip to content

add github action build #6

add github action build

add github action build #6

Workflow file for this run

name: Build
on:
workflow_dispatch:
push:
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: write
strategy:
matrix:
target:
- windows-amd64
- windows-arm64
- windows-386
- darwin-amd64
- darwin-arm64
- linux-amd64
- linux-arm64
- linux-arm
- linux-386
version:
- { name: '1.20', tag: '1.20.14'}
- { name: '1.21', tag: '1.21.13'}
- { name: '1.22', tag: '1.22.12'}
- { name: '1.23', tag: '1.23.12'}
- { name: '1.24', tag: '1.24.13'}
- { name: '1.25', tag: '1.25.8'}
- { name: '1.26', tag: '1.26.1'}
fail-fast: false
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v6
with:
repository: golang/go
ref: go${{ matrix.version.tag }}
path: go
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: "go/src/go.mod"
cache: false
- name: Apply patch
if: ${{ matrix.version.name != '1.20' }}
run: |
cd go
patch --verbose -p 1 < $GITHUB_WORKSPACE/go${{matrix.version.name}}.patch
- name: Set execute permissions
run: |
chmod +x go/src/make.bash
- name: Build Go toolchain
env:
GOOS: ${{ startsWith(matrix.target, 'windows-') && 'windows' || startsWith(matrix.target, 'darwin-') && 'darwin' || 'linux' }}
GOARCH: ${{ endsWith(matrix.target, '-386') && '386' || endsWith(matrix.target, '-amd64') && 'amd64' || endsWith(matrix.target, '-arm64') && 'arm64' || 'arm' }}
CGO_ENABLED: 0
run: |
cd go/src
./make.bash
- name: Create release directory
run: |
mkdir -p release
cp -r go release/
cd release/go
# Remove development files
rm -rf .git*
- name: Package
run: |
mkdir -p artifact
cd release
if [[ "${{ matrix.target }}" == windows_* ]]; then
zip -r ../artifact/go${{ matrix.version.name }}.${{ matrix.target }}.zip .
else
tar -czf ../artifact/go${{ matrix.version.name }}.${{ matrix.target }}.tar.gz .
fi
- name: Update Artifact
uses: actions/upload-artifact@v7
with:
path: artifact/*
archive: false
merge:
permissions: write-all
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v6
- name: Download All Artifacts
uses: actions/download-artifact@v8
with:
path: bin
pattern: go*
merge-multiple: true
- name: Add patch files
run: |
cp go*.patch bin/
- name: Upload Release
uses: softprops/action-gh-release@v2
if: ${{ success() }}
with:
tag_name: build
files: bin/*