Excavator: Manage go version #902
Workflow file for this run
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: Build | |
on: | |
push: | |
branches: [develop] | |
tags-ignore: | |
- '**' | |
pull_request: | |
release: | |
types: [published] | |
jobs: | |
Verify: | |
runs-on: ubuntu-latest | |
env: | |
GOPATH: /home/runner/go | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Go version | |
id: go_version | |
run: | | |
GO_VERSION=$(cat .palantir/go-version | sed 's/^go//' ) | |
echo "::set-output name=version::${GO_VERSION}" | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ steps.go_version.outputs.version }} | |
- name: Cache Godel assets | |
uses: actions/cache@v3 | |
with: | |
path: ~/.godel | |
key: ${{ runner.os }}-godel-${{ hashFiles('godelw', 'godel/config/godel.yml') }} | |
restore-keys: | | |
${{ runner.os }}-godel- | |
- name: Verify | |
run: ./godelw verify --apply=false | |
Dist: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
needs: | |
- Verify | |
env: | |
GOPATH: /home/runner/go | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set Go version | |
id: go_version | |
run: | | |
GO_VERSION=$(cat .palantir/go-version | sed 's/^go//' ) | |
echo "::set-output name=version::${GO_VERSION}" | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: ${{ steps.go_version.outputs.version }} | |
- name: Cache Godel assets | |
uses: actions/cache@v3 | |
with: | |
path: ~/.godel | |
key: ${{ runner.os }}-godel-${{ hashFiles('godelw', 'godel/config/godel.yml') }} | |
restore-keys: | | |
${{ runner.os }}-godel- | |
- name: Set up Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Cache node_modules | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-node-modules-${{ hashFiles('yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node-modules- | |
- name: Install frontend dependencies | |
run: yarn install | |
- name: Build frontend | |
run: yarn run build:production | |
- name: Build distribution | |
run: ./godelw dist | |
- name: Build Docker image | |
run: ./godelw docker build --verbose | |
- name: Archive distribution | |
uses: actions/upload-artifact@v4 | |
with: | |
name: dist | |
path: | | |
build/policy-bot/*/bin/*.tgz | |
# | |
# Steps after this point should only run when publishing | |
# Include them here to avoid exporting the Docker container as an artifact | |
# | |
- name: Login to Docker Hub | |
if: ${{ github.event_name == 'push' || github.event_name == 'release' }} | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
- name: Push snapshot image to Docker Hub | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/develop' }} | |
run: ./godelw docker push --tags=snapshot | |
- name: Push release image to Docker Hub | |
if: ${{ github.event_name == 'release' }} | |
run: ./godelw docker push --tags=latest,version | |
- name: Publish release assets | |
if: ${{ github.event_name == 'release' }} | |
run: ./godelw publish github --add-v-prefix --api-url=${GITHUB_API_URL} --user=palantir --repository=policy-bot --token=${{ secrets.GITHUB_TOKEN }} |