Svelte: some unrelated cleanups (#63757) #34
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: sg-binary-release | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
# Core sg code | |
- 'dev/sg/**' | |
- '.github/workflows/sg-binary-release.yml' | |
# Core sg dependencies | |
- 'lib/output/**' | |
- 'lib/errors/**' | |
- 'lib/group/**' | |
# Important things sg imports | |
- 'dev/ci/images/**' # sg ops | |
- 'internal/database/migration/**' # sg migration | |
- 'monitoring/**' # sg monitoring | |
- 'dev/managedservicesplatform/**' # sg msp | |
# manual release | |
workflow_dispatch: {} | |
env: | |
GOFLAGS: -trimpath | |
CGO_ENABLED: '1' | |
jobs: | |
touch_sg: | |
if: github.repository == 'sourcegraph/sourcegraph' | |
name: Touch sourcegraph/sg | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout-sourcegraph-sg | |
uses: actions/checkout@v3 | |
with: | |
repository: sourcegraph/sg | |
token: ${{ secrets.SG_RELEASE_TOKEN }} | |
- name: touch-sourcegraph-sg | |
run: | | |
today=$(date +'%Y-%m-%d-%H-%M') | |
sed -i 's/Latest release: .*/Latest release: '"$today"'/' README.md | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add README.md | |
git commit -m "Update to latest release" | |
git push | |
create_release: | |
name: create-github-release | |
needs: touch_sg | |
runs-on: ubuntu-latest | |
outputs: | |
release_name: ${{ steps.release.outputs.release_name }} | |
steps: | |
- name: create-github-release | |
id: release | |
run: | | |
today=$(date +'%Y-%m-%d-%H-%M') | |
short_sha=$(echo ${{ github.sha }} | cut -c1-8) | |
# ATTENTION: release_name is a duplicate from the last step in this | |
# file, because I can't get workflow outputs to work. If you change | |
# one, make sure you change the other. | |
release_name="${today}-${short_sha}" | |
echo "### sg snapshot release" >> /tmp/release-notes.md | |
echo "" >> /tmp/release-notes.md | |
echo "Commit: https://github.com/sourcegraph/sourcegraph/commit/${{github.sha}}" >> /tmp/release-notes.md | |
gh release delete -R="${repo}" ${release_name} || true | |
gh release create -R="${repo}" ${release_name} --notes-file /tmp/release-notes.md | |
echo "::set-output name=release_name::${release_name}" | |
env: | |
repo: sourcegraph/sg | |
GITHUB_TOKEN: ${{ secrets.SG_RELEASE_TOKEN }} | |
build: | |
name: build | |
needs: [create_release] | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
os: | |
- ubuntu-latest | |
- macos-latest | |
arch: | |
- amd64 | |
- arm64 | |
exclude: | |
# Compiling for arm64 on Linux requires more work | |
- os: ubuntu-latest | |
arch: arm64 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Install Go | |
uses: actions/setup-go@v4 | |
with: { go-version: '1.22' } | |
- name: Build and upload macOS | |
if: startsWith(matrix.os, 'macos-') == true | |
run: | | |
cd dev/sg | |
GOARCH=${{ matrix.arch }} go build -o "sg_$(go env GOOS)_${{ matrix.arch }}" -trimpath \ | |
-ldflags "-s -w -X main.BuildCommit=$(git rev-list -1 HEAD .) -X main.ReleaseName=${{ needs.create_release.outputs.release_name }}" . | |
- name: Build and upload Linux | |
if: startsWith(matrix.os, 'ubuntu-') == true | |
run: | | |
cd dev/sg | |
GOARCH=${{ matrix.arch }} go build -o "sg_$(go env GOOS)_${{ matrix.arch }}" -trimpath \ | |
-ldflags "-s -w -X main.BuildCommit=$(git rev-list -1 HEAD .) -X main.ReleaseName=${{ needs.create_release.outputs.release_name }}" . | |
# On certain CI agents, the glibc might not be the right one, so we build a static variant | |
CGO_ENABLED=0 GOARCH=${{ matrix.arch }} go build -o "sg_$(go env GOOS)_${{ matrix.arch }}_static" -trimpath \ | |
-ldflags "-s -w -X main.BuildCommit=$(git rev-list -1 HEAD .) -X main.ReleaseName=${{ needs.create_release.outputs.release_name }}" . | |
- name: Upload release asset | |
run: | | |
cd dev/sg | |
release_name="${{ needs.create_release.outputs.release_name }}" | |
gh release upload -R="${repo}" ${release_name} "sg_$(go env GOOS)_${{ matrix.arch }}" | |
env: | |
repo: sourcegraph/sg | |
GITHUB_TOKEN: ${{ secrets.SG_RELEASE_TOKEN }} | |
- name: Upload release asset (linux-amd64-static) | |
if: startswith(matrix.os, 'ubuntu-') == true | |
run: | | |
cd dev/sg | |
release_name="${{ needs.create_release.outputs.release_name }}" | |
gh release upload -R="${repo}" ${release_name} "sg_$(go env GOOS)_${{ matrix.arch }}_static" | |
env: | |
repo: sourcegraph/sg | |
GITHUB_TOKEN: ${{ secrets.SG_RELEASE_TOKEN }} | |
report_failure: | |
needs: build | |
if: ${{ failure() }} | |
uses: sourcegraph/sourcegraph/.github/workflows/report-job-failure.yml@main | |
secrets: inherit |