Release #52
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: "Release" | |
on: | |
push: | |
tags: | |
- "v[0-9]+.[0-9]+.[0-9]+*" | |
jobs: | |
goreleaser: | |
name: 'Build and release packages' | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write # For cosign | |
packages: write # For GHCR | |
contents: read # Not required for public repositories, but for clarity | |
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 | |
uses: sigstore/cosign-installer@v3.5.0 | |
- name: Import GPG key | |
id: gpg | |
run: | | |
GPG_KEY_FILE=/tmp/signing-key.gpg | |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode > "${GPG_KEY_FILE}" | |
echo "${{ secrets.GPG_PRIVATE_KEY }}" | base64 --decode | gpg --batch --passphrase "${{ secrets.GPG_PASSPHRASE }}" --import | |
GPG_FINGERPRINT=$(gpg --list-secret-keys --keyid-format LONG | awk '/^sec/{sub(/.*\//, "", $2); print $2; exit}') | |
echo "GPG_FINGERPRINT=${GPG_FINGERPRINT}" >>"${GITHUB_ENV}" | |
echo "GPG_KEY_FILE=${GPG_KEY_FILE}" >> "${GITHUB_ENV}" | |
env: | |
GPG_TTY: /dev/ttys000 # Set the GPG_TTY to avoid issues with pinentry | |
- name: Setup snapcraft | |
run: | | |
sudo snap install snapcraft --classic --channel=7.x/stable | |
# See https://github.com/goreleaser/goreleaser/issues/1715 | |
mkdir -p "$HOME/.cache/snapcraft/download" | |
mkdir -p "$HOME/.cache/snapcraft/stage-packages" | |
env: | |
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_TOKEN }} | |
- 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 }} | |
SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_STORE_TOKEN }} | |
GPG_KEY_FILE: ${{ steps.gpg.outputs.GPG_KEY_FILE }} | |
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }} | |
GPG_FINGERPRINT: ${{ steps.gpg.outputs.GPG_FINGERPRINT }} | |
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 }} |