Skip to content

Merge pull request #11 from smlx/batman #10

Merge pull request #11 from smlx/batman

Merge pull request #11 from smlx/batman #10

Workflow file for this run

name: Release
on:
push:
branches:
- main
jobs:
tag:
permissions:
contents: write
runs-on: ubuntu-latest
outputs:
new-tag: ${{ steps.bump-tag.outputs.new }}
new-tag-version: ${{ steps.bump-tag.outputs.new_tag_version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config --global user.name "$GITHUB_ACTOR"
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: stable
- name: Install ccv
run: >
curl -sSL https://github.com/smlx/ccv/releases/download/v0.3.2/ccv_0.3.2_linux_amd64.tar.gz
| sudo tar -xz -C /usr/local/bin ccv
- name: Bump tag if necessary
id: bump-tag
run: |
if [ -z $(git tag -l $(ccv)) ]; then
git tag $(ccv)
git push --tags
echo "new=true" >> $GITHUB_OUTPUT
echo "new_tag_version=$(git tag --points-at HEAD)" >> $GITHUB_OUTPUT
fi
release:
permissions:
contents: write
needs: tag
if: needs.tag.outputs.new-tag == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Go
uses: actions/setup-go@v4
with:
go-version: stable
- name: Set up environment
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tar up binaries
run: tar -cvf dist.tar dist
- name: Upload binaries tar file
uses: actions/upload-artifact@v3
with:
name: dist.tar
path: dist.tar
releaseimage:
permissions:
contents: read
packages: write
strategy:
matrix:
binary:
- sems_mitm_exporter
needs:
- tag
- release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download binaries tar file
uses: actions/download-artifact@v3
with:
name: dist.tar
- name: Untar binaries
run: tar -xvf dist.tar
- name: Login to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
# this id is namespaced per matrix run
id: docker_metadata
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.binary }}
tags: |
${{ needs.tag.outputs.new-tag-version }}
latest
- name: Build and push ${{ matrix.binary }} container image
id: docker_build
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
file: deploy/docker/Dockerfile
context: dist/${{ matrix.binary }}_linux_amd64_v1
build-args: |
BINARY=${{ matrix.binary }}