Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 89 additions & 0 deletions .github/workflows/goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,63 @@ on:
- '!latest'

jobs:
# goreleaser-pre copies the main formula in our Homebrew tap for the last release
# (second latest tag) to a versioned formula, so that it is preserved when goreleaser
# runs and overwrites the main formula with the latest build.
goreleaser-pre:
name: Copy previous release
runs-on: ubuntu-latest
outputs:
second_latest_tag: ${{ env.second_latest_tag }}
latest_tag: ${{ env.latest_tag }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Fetch latest and second-latest tags
run: |
echo "second_latest_tag=$(git tag --sort=taggerdate | tail -2 | sed -n 1p)" >> $GITHUB_ENV
echo "latest_tag=$(git tag --sort=taggerdate | tail -1)" >> $GITHUB_ENV
- name: Set versioning variables
run: |
echo "versioned_formula_file=Formula/src-cli@${{ env.second_latest_tag }}.rb" >> $GITHUB_ENV
echo "versioned_classname=SrcCliAT$(echo ${{ env.second_latest_tag }} | sed 's/\.//g')" >> $GITHUB_ENV
- name: Log variables
run: |
echo "Second latest tag: ${{ env.second_latest_tag }}"
echo "Versioned formula file: ${{ env.versioned_formula_file }}"
echo "Versioned classname: ${{ env.versioned_classname }}"
- name: Checkout Homebrew tap
uses: actions/checkout@v3
with:
repository: sourcegraph/homebrew-src-cli
fetch-depth: 0
token: ${{ secrets.BOT_CROSS_REPO_PAT }}
- name: Copy main release formula file to versioned formula file
run: cp Formula/src-cli.rb ${{ env.versioned_formula_file }}
# Homebrew expects the name of the class in a versioned formula file to be of the
# format {Formula}AT{Major}{Minor}{Patch}, but the main formula classname is just
# {Formula}, so we manually patch the name: SrcCli -> SrcCliAT###
- name: Rename formula classname
run: sed -i 's/class SrcCli/class ${{ env.versioned_classname }}/' ${{ env.versioned_formula_file }}
- name: Commit result
run: |
git config user.name sourcegraph-bot
git config user.email sourcegraph-bot-github@sourcegraph.com
git add .
git commit -m "Copy previous release"
git push

goreleaser:
name: release
runs-on: ubuntu-latest
needs: goreleaser-pre
# Passthrough for the outputs from the first job so that they're also available in
# goreleaser-post
outputs:
second_latest_tag: ${{ needs.goreleaser-pre.outputs.second_latest_tag }}
latest_tag: ${{ needs.goreleaser-pre.outputs.latest_tag }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -33,6 +87,41 @@ jobs:
env:
# Use separate access token, because we need a scope:repo token to publish the brew formula.
GITHUB_TOKEN: ${{ secrets.GH_PAT }}

# goreleaser-post updates the symlink name to refer to the new release version. The
# symlink enables users to install the latest src-cli with the versioned command:
# $ brew install sourcegraph/src-cli/src-cli@X.Y.Z
# alongside the command to install it via the main formula:
# $ brew install sourcegraph/src-cli/src-cli
goreleaser-post:
name: Create new release version symlink
runs-on: ubuntu-latest
needs: goreleaser
steps:
- name: Set variables
run: |
echo "old_symlink_name=Aliases/src-cli@${{ needs.goreleaser.outputs.second_latest_tag }}" >> $GITHUB_ENV
echo "new_symlink_name=Aliases/src-cli@${{ needs.goreleaser.outputs.latest_tag }}" >> $GITHUB_ENV
- name: Log variables
run: |
echo "Old symlink: ${{ env.old_symlink_name }}"
echo "New symlink: ${{ env.new_symlink_name }}"
- name: Checkout Homebrew tap
uses: actions/checkout@v3
with:
repository: sourcegraph/homebrew-src-cli
fetch-depth: 0
token: ${{ secrets.BOT_CROSS_REPO_PAT }}
- name: Replace symlink
run: mv ${{ env.old_symlink_name }} ${{ env.new_symlink_name }}
- name: Commit result
run: |
git config user.name sourcegraph-bot
git config user.email sourcegraph-bot-github@sourcegraph.com
git add .
git commit -m "Update latest release symlink"
git push

npm:
runs-on: ubuntu-latest
needs: goreleaser
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/lsif.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: LSIF
on:
- push

jobs:
lsif-go:
runs-on: ubuntu-latest
Expand Down
8 changes: 8 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ curl -L https://sourcegraph.example.com/.api/src-cli/src_darwin_amd64 -o /usr/lo
chmod +x /usr/local/bin/src
```

or, if you know the specific version to target, for example 3.43.2:

```bash
brew install sourcegraph/src-cli/src-cli@3.43.2
```

> Note: Versioned formulas are available on Homebrew for Sourcegraph versions 3.43.2 and later.

### Installation: Linux

#### Latest version
Expand Down