Skip to content

ci(goreleaser): fix Go 1.11 WindowsXP build with vendor+goregexp #34

ci(goreleaser): fix Go 1.11 WindowsXP build with vendor+goregexp

ci(goreleaser): fix Go 1.11 WindowsXP build with vendor+goregexp #34

Workflow file for this run

name: nightly
on:
push:
branches:
- master
workflow_dispatch:
permissions:
contents: write
jobs:
nightly:
runs-on: ubuntu-22.04
steps:
-
name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
submodules: recursive
-
name: Set nightly tag
run: |
DATE=$(date -u +%Y%m%d)
echo "DATE=$DATE" >> $GITHUB_ENV
echo "TAG=v0.0.0-nightly.$DATE" >> $GITHUB_ENV
echo "RELEASE_NAME=Nightly $DATE" >> $GITHUB_ENV
-
name: Create or update nightly tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f "$TAG"
git push --force origin "$TAG"
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.17'
-
name: Install upx
run: sudo apt install upx zip -y
continue-on-error: true
-
name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean --skip=validate
workdir: v2/
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOPATH: "/home/runner/go"
- name: cat mod
run: cat v2/go.mod
# go1.11 can't parse a `go 1.24.0` go.mod, so build the WindowsXP binaries
# in GOPATH mode from a vendored tree. cmd/tinygo is excluded (it needs the
# tinygo compiler + rem/x/netdev); goregexp selects fingers' stdlib-regexp
# fallback so go-re2/wazero (go1.16+) aren't pulled in.
- name: Prepare go1.11 vendor tree
shell: bash
run: |
set -euo pipefail
export GOPATH111="${RUNNER_TEMP}/go111-gopath"
src="${GOPATH111}/src/github.com/chainreactors/gogo/v2"
mkdir -p "$(dirname "$src")"
rsync -a --delete \
--exclude '.git' --exclude '.toolchain' --exclude 'dist' \
--exclude 'vendor' --exclude '*.exe' --exclude 'cmd/tinygo' \
v2/ "$src/"
cd "$src"
go mod vendor
- name: Set up Go 1.11
uses: actions/setup-go@v5
with:
go-version: '1.11.13'
- name: Compile WindowsXP binaries with Go 1.11
shell: bash
run: |
set -euo pipefail
export GOPATH="${RUNNER_TEMP}/go111-gopath"
cd "${GOPATH}/src/github.com/chainreactors/gogo/v2"
mkdir -p "${GITHUB_WORKSPACE}/v2/dist"
for arch in amd64 386; do
GO111MODULE=off GOOS=windows GOARCH="$arch" CGO_ENABLED=0 \
go build \
-o "${GITHUB_WORKSPACE}/v2/dist/gogo_windowsxp_${arch}.exe" \
-ldflags "-s -w -X 'github.com/chainreactors/gogo/v2/internal/core.ver=${TAG}'" \
-tags="forceposix goregexp" .
done
- name: Zip files
run: zip -r v2/dist/gogo_archive.zip v2/dist/gogo* tools/* README.md
- name: Upload binaries to release
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: v2/dist/gogo*
tag: ${{ env.TAG }}
overwrite: true
file_glob: true
prerelease: true
release_name: ${{ env.RELEASE_NAME }}