on: push: # Sequence of patterns matched against refs/tags tags: - 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10 branches: - dev pull_request: branches: ['*'] name: Latest Release defaults: run: shell: bash jobs: lint: name: Lint files runs-on: 'ubuntu-latest' steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 with: go-version: '1.23' - name: golangci-lint uses: golangci/golangci-lint-action@v8.0.0 with: version: latest release: permissions: contents: write name: Create Release runs-on: 'ubuntu-latest' if: startsWith(github.ref, 'refs/tags/v') strategy: matrix: # List of GOOS and GOARCH pairs from `go tool dist list` goosarch: - 'linux/amd64' - 'linux/386' - 'linux/arm64' - 'linux/arm' steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 - uses: actions/setup-go@v4 with: go-version: '1.23' - name: Get OS and arch info run: | GOOSARCH=${{matrix.goosarch}} GOOS=${GOOSARCH%/*} GOARCH=${GOOSARCH#*/} BINARY_NAME=explo-$GOOS-$GOARCH echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV echo "GOOS=$GOOS" >> $GITHUB_ENV echo "GOARCH=$GOARCH" >> $GITHUB_ENV - name: Build binary run: | go build -o "$BINARY_NAME" -v ./src/main/ - name: Release uses: softprops/action-gh-release@v1 with: draft: true files: ${{env.BINARY_NAME}} token: ${{ secrets.GITHUB_TOKEN }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build: name: Build/publish container image runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') # only build latest from tagged versions needs: release permissions: contents: read packages: write id-token: write steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Login to ghcr.io uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Convert repository name to lowercase run: | REPO_LC=$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]') echo "REPO_LC=$REPO_LC" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build and push id: build-and-push uses: docker/build-push-action@v5 with: context: . push: true tags: | ghcr.io/${{ env.REPO_LC }}:latest ghcr.io/${{ env.REPO_LC }}:${{ github.ref_name }} cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7 build-args: | TARGETARCH build-dev: name: Build/publish dev image runs-on: ubuntu-latest if: github.ref == 'refs/heads/dev' permissions: contents: read packages: write id-token: write concurrency: group: dev-${{ github.ref }} cancel-in-progress: true steps: - name: Checkout repository uses: actions/checkout@v4 with: fetch-depth: 0 - name: Login to ghcr.io uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Convert repository name to lowercase run: echo "REPO_LC=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 - name: Build and push dev image uses: docker/build-push-action@v5 with: context: . push: true tags: ghcr.io/${{ env.REPO_LC }}:dev cache-from: type=gha cache-to: type=gha,mode=max platforms: linux/amd64,linux/386,linux/arm64,linux/arm/v7 build-args: | TARGETARCH