diff --git a/.gitea/workflows/release.yml b/.gitea/workflows/release.yml index e0a166a..02458e0 100644 --- a/.gitea/workflows/release.yml +++ b/.gitea/workflows/release.yml @@ -1,127 +1,57 @@ -# .gitea/workflows/release.yml - -name: Build and Release Docker Image +name: release-tag on: push: branches: - - main # Or your default branch, e.g., master - tags: - - 'v*.*.*' # Trigger on version tags like v1.0.0, v1.2.3-alpha - pull_request: # Optional: build on PRs for testing, no push or release - branches: - - main # Or your default branch - -env: - # Assumes your Gitea instance FQDN is correctly identified by gitea.instance - # e.g., gitea.example.com - # The image will be named: //: - REGISTRY_HOST: ${{ gitea.instance }} - IMAGE_NAME_PATH: ${{ gitea.owner }}/${{ gitea.repository_name }} + - master jobs: - build-and-push-image: - runs-on: ubuntu-latest # Ensure your Gitea runner supports Docker + release-image: + runs-on: ubuntu-latest + env: + DOCKER_LATEST: nightly + CONTAINER_NAME: drb-client-discord-bot steps: - - name: Checkout code + - name: Checkout uses: actions/checkout@v4 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 - - name: Login to Gitea Container Registry - # Ensure GITEA_TOKEN secret is created in your repository settings. - # It needs permissions to write to packages (container registry). - # gitea.actor is the user who triggered the workflow. + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v3 + with: # replace it with your local IP + config-inline: | + [registry."git.vpn.cusano.net"] + http = false + insecure = false + + - name: Login to DockerHub uses: docker/login-action@v3 with: - registry: ${{ env.REGISTRY_HOST }} - username: ${{ gitea.actor }} - password: ${{ secrets.GITEA_TOKEN }} - - - name: Extract Docker metadata + registry: git.vpn.cusano.net # replace it with your local IP + username: ${{ secrets.GIT_REPO_USERNAME }} + password: ${{ secrets.GIT_REPO_PASSWORD }} + + - name: Get Meta id: meta - uses: docker/metadata-action@v5 + run: | + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT + echo REPO_VERSION=$(git describe --tags --always | sed 's/^v//') >> $GITHUB_OUTPUT + + - name: Validate build configuration + uses: docker/build-push-action@v6 with: - images: ${{ env.REGISTRY_HOST }}/${{ env.IMAGE_NAME_PATH }} - tags: | - # For pushes to the default branch (e.g., main) - type=raw,value=latest,enable={{is_default_branch}} - type=sha,prefix=,format=short,enable={{is_default_branch}} # e.g., sha-1234567 + call: check - # For version tags like v1.2.3 - # Produces: 1.2.3 from tag v1.2.3 - type=semver,pattern={{version}} - # Produces: 1.2 from tag v1.2.3 - type=semver,pattern={{major}}.{{minor}} - # Produces: 1 from tag v1.2.3 - type=semver,pattern={{major}} - # Also tag vX.Y.Z as 'latest' - type=raw,value=latest,enable=${{ startsWith(gitea.ref, 'refs/tags/v') }} - - - name: Build and push Docker image - uses: docker/build-push-action@v5 + - name: Build and push + uses: docker/build-push-action@v6 with: context: . file: ./Dockerfile - # Only push if it's not a pull request event - push: ${{ gitea.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - # Enable build cache using Gitea Actions cache - cache-from: type=gha - cache-to: type=gha,mode=max - - create-gitea-release: - needs: build-and-push-image - # Only run this job if the trigger was a tag push matching 'v*.*.*' - if: startsWith(gitea.ref, 'refs/tags/v') - runs-on: ubuntu-latest - steps: - - name: Get tag name - id: get_tag - # GITEA_REF is like 'refs/tags/v1.2.3', this extracts 'v1.2.3' - run: echo "TAG_NAME=${GITEA_REF#refs/tags/}" >> $GITEA_ENV - - - name: Create Gitea Release - env: - # GITEA_TOKEN needs permissions to create releases (e.g., repository:write). - # It can be the same token used for registry login if it has sufficient scope. - GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} - TAG_NAME: ${{ env.TAG_NAME }} # From previous step - OWNER: ${{ gitea.owner }} - REPO: ${{ gitea.repository_name }} - # gitea.server_url is like https://gitea.example.com - GITEA_API_URL: ${{ gitea.server_url }}/api/v1 - run: | - echo "Creating Gitea release for tag: $TAG_NAME" - RELEASE_API_ENDPOINT="$GITEA_API_URL/repos/$OWNER/$REPO/releases" - - # You can customize the release body, e.g., by fetching changelog notes - RELEASE_BODY="Official release for version $TAG_NAME." - - # Create the release using Gitea API - response=$(curl --request POST \ - --url "$RELEASE_API_ENDPOINT" \ - --header "Authorization: token $GITEA_TOKEN" \ - --header "Content-Type: application/json" \ - --data @- <