filebrowser/.github/workflows/release.yaml

79 lines
2.5 KiB
YAML
Raw Normal View History

name: release
on:
push:
branches:
2024-08-04 14:56:18 +00:00
- "v[0-9]+.[0-9]+.[0-9]+"
2024-06-12 19:51:13 +00:00
permissions:
contents: write
jobs:
2024-06-12 19:51:13 +00:00
create_release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
2024-08-04 14:56:18 +00:00
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT }}
2024-06-12 19:51:13 +00:00
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
2024-08-04 14:56:18 +00:00
- uses: actions/setup-go@v5
with:
go-version: 1.22.2
2024-06-12 19:51:13 +00:00
- name: Create Release
2024-08-04 14:56:18 +00:00
uses: softprops/action-gh-release@v2
2024-06-12 19:51:13 +00:00
with:
2024-08-04 14:56:18 +00:00
target_commitish: ${{ steps.extract_branch.outputs.branch }}
token: ${{ secrets.PAT }}
2024-06-12 19:51:13 +00:00
tag_name: ${{ steps.extract_branch.outputs.branch }}
prerelease: false
2024-08-04 14:56:18 +00:00
draft: false
generate_release_notes: true
name: ${{ steps.extract_branch.outputs.branch }}
push_release_to_registry:
name: Push release
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3.0.0
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.0.0
# Workaround to fix error:
# failed to push: failed to copy: io: read/write on closed pipe
# See https://github.com/docker/build-push-action/issues/761
with:
driver-opts: |
image=moby/buildkit:v0.10.6
- name: Login to Docker Hub
# Only push to Docker Hub when making a release
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
2024-07-30 17:45:27 +00:00
uses: docker/metadata-action@v5
with:
images: gtstef/filebrowser
2023-10-10 14:34:54 +00:00
- name: Strip v from version number
2023-10-10 13:25:14 +00:00
id: modify-json
2023-10-10 13:09:59 +00:00
run: |
2023-10-10 13:46:33 +00:00
JSON="${{ steps.meta.outputs.tags }}"
2023-10-10 13:25:14 +00:00
# Use jq to remove 'v' from the version field
2023-10-10 13:53:26 +00:00
JSON=$(echo "$JSON" | sed 's/filebrowser:v/filebrowser:/')
2023-10-10 14:34:54 +00:00
echo "cleaned_tag=$JSON" >> $GITHUB_OUTPUT
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64,linux/arm/v7
file: ./Dockerfile
push: true
2023-10-10 13:46:33 +00:00
tags: ${{ steps.modify-json.outputs.cleaned_tag }}
2023-10-10 13:31:36 +00:00
labels: ${{ steps.meta.outputs.labels }}