Skip to content

add GitHub Actions support (#96) #21

add GitHub Actions support (#96)

add GitHub Actions support (#96) #21

Workflow file for this run

---
name: "Release"
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
jobs:
goreleaser:
name: 'Build and release packages'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.21
- name: Install Cosign
run: |
curl -O -L "https://github.com/sigstore/cosign/releases/latest/download/cosign-linux-amd64"
mv cosign-linux-amd64 /usr/local/bin/cosign
chmod +x /usr/local/bin/cosign
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
with:
distribution: goreleaser
version: latest
args: release --clean -f ${{ vars.GORELEASER_CONFIG_PATH }}
env:
GITHUB_TOKEN: ${{ secrets.TENV_GITHUB_TOKEN }}
docker-ghcr:
name: 'Build and release docker image to github container registry'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/tofuutils/tenv:${{ github.ref_name }}, ghcr.io/tofuutils/tenv:latest
docker-dockerhub:
name: 'Build and release docker image to dockerhub'
runs-on: ubuntu-latest
env:
registry_url: "registry.hub.docker.com"
image_repo: "tofuutils/tenv"
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry_url }}
username: ${{ secrets.REGISTRY_USER }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Build and push docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ${{ env.registry_url }}/${{ env.image_repo }}:latest, ${{ env.registry_url }}/${{ env.image_repo }}:${{ github.ref_name }}