Skip to content

refactor: refine business logic separation #18

refactor: refine business logic separation

refactor: refine business logic separation #18

Workflow file for this run

name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
with:
tag_name: ${{ github.ref_name }}
release_name: ${{ github.ref_name }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
release-binary:
needs: release
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, windows, darwin]
arch: [amd64, arm64]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.24.2
- name: Build
run: go mod tidy && go build -ldflags "-X main.version=${{ github.ref_name }}" -o gitlab-sync_${{ matrix.os }}_${{ matrix.arch }} cmd/main.go
env:
GOOS: ${{ matrix.os }}
GOARCH: ${{ matrix.arch }}
CGO_ENABLED: 0
GO111MODULE: on
- name: Upload binaries
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ needs.release.outputs.upload_url }}
asset_path: ./gitlab-sync_${{ matrix.os }}_${{ matrix.arch }}
asset_name: gitlab-sync_${{ github.ref_name }}_${{ matrix.os }}_${{ matrix.arch }}
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
release-oci:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up version variables
id: vars
run: |
VERSION=${{ github.ref_name }}
MAJOR=$(echo $VERSION | cut -d. -f1)
MINOR=$(echo $VERSION | cut -d. -f2)
REPO_NAME=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]')
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "MAJOR=$MAJOR" >> $GITHUB_ENV
echo "MINOR=$MINOR" >> $GITHUB_ENV
echo "REPO_NAME=$REPO_NAME" >> $GITHUB_ENV
echo "CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: Containerfile
push: true
sbom: true
build-args: |
VERSION=${{ github.ref_name }}
labels: |
org.opencontainers.image.title=${{ github.event.repository.name }}
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.source=${{ github.event.repository.html_url }}
org.opencontainers.image.url=ghcr.io/boxboxjason/gitlab-sync
org.opencontainers.image.created=${{ env.CREATED }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.version=${{ github.ref_name }}
org.opencontainers.image.vendor=${{ github.repository_owner}}
tags: |
ghcr.io/${{ env.REPO_NAME }}:${{ github.ref_name }}
ghcr.io/${{ env.REPO_NAME }}:${{ env.MAJOR }}.${{ env.MINOR }}
ghcr.io/${{ env.REPO_NAME }}:${{ env.MAJOR }}
ghcr.io/${{ env.REPO_NAME }}:latest
- name: Release Changelog Builder
uses: mikepenz/release-changelog-builder-action@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}