Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 69 additions & 65 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
# بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
# This file is part of forehead.
#
# Copyright (C) 2026-Present Afsall Inc.
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Alternatively, this file is available under the MIT License:
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: CD
on:
push:
Expand Down Expand Up @@ -65,46 +28,87 @@ jobs:
echo "changed=true" >> "$GITHUB_OUTPUT"
fi

publish:
changelog:
needs: detect
if: needs.detect.outputs.changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- name: Publish forehead-core
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
if ! curl -s "https://crates.io/api/v1/crates/forehead-core" | grep -q "\"version\":\"$VERSION\""; then
cargo publish -p forehead-core
else
echo "forehead-core v$VERSION already exists, skipping"
fi
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Publish forehead-cli
- uses: Swatinem/rust-cache@v2
- name: Install changelogger
run: cargo install changelogger-cli --version 0.2.2
- name: Generate CHANGELOG
run: changelogger changelog generate --dir prdoc --output CHANGELOG.md --release "${{ needs.detect.outputs.version }}"
- name: Commit and tag
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
if ! curl -s "https://crates.io/api/v1/crates/forehead-cli" | grep -q "\"version\":\"$VERSION\""; then
cargo publish -p forehead-cli
else
echo "forehead-cli v$VERSION already exists, skipping"
fi
VERSION=${{ needs.detect.outputs.version }}
git config user.name "changelogger-bot"
git config user.email "bot@github.com"
git add CHANGELOG.md
git commit -m "changelog: auto-generate for v${VERSION}" || true
git tag "v${VERSION}"
git push origin "v${VERSION}"

crates-io:
needs: detect
if: needs.detect.outputs.changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install changelogger
run: cargo install changelogger-cli --version 0.2.2
- name: Publish to crates.io
run: changelogger publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
- name: Install changelogger
run: cargo install changelogger-cli --version 0.2.1

- name: Generate and update CHANGELOG.md
run: |
VERSION=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
changelogger changelog generate --from "v${VERSION}" --output CHANGELOG.md
changelogger changelog bump --current "$VERSION" --from "v${VERSION}"
git add CHANGELOG.md
git commit -m "chore: update CHANGELOG.md for v${VERSION}" || true
container:
needs: detect
if: needs.detect.outputs.changed == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}},value=v${{ needs.detect.outputs.version }}
type=semver,pattern={{major}}.{{minor}},value=v${{ needs.detect.outputs.version }}
type=raw,value=latest
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
114 changes: 0 additions & 114 deletions .github/workflows/command-prdoc.yml

This file was deleted.

65 changes: 13 additions & 52 deletions .github/workflows/prdoc.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,3 @@
# بِسْمِ اللَّهِ الرَّحْمَنِ الرَّحِيم
# This file is part of forehead.
#
# Copyright (C) 2026-Present Afsall Inc.
# SPDX-License-Identifier: Apache-2.0 OR MIT
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Alternatively, this file is available under the MIT License:
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

name: PRDoc
on:
pull_request:
Expand All @@ -52,10 +15,13 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.head_ref }}

- name: Install Rust
uses: dtolnay/rust-toolchain@v1
with:
toolchain: stable
- uses: Swatinem/rust-cache@v2
- name: Install changelogger
run: cargo install changelogger-cli --version 0.2.1

run: cargo install changelogger-cli --version 0.2.2
- name: Generate PRDoc
id: generate
env:
Expand All @@ -64,28 +30,23 @@ jobs:
PR_NUM=${{ github.event.pull_request.number }}
PRDOC="prdoc/pr_${PR_NUM}.prdoc"
if [ -f "$PRDOC" ]; then
echo "PRDoc already exists at $PRDOC — validating only"
echo "PRDoc already exists — validating only"
echo "generated=false" >> "$GITHUB_OUTPUT"
else
changelogger prdoc generate --pr "$PR_NUM" --force --bump patch
changelogger prdoc generate --pr "$PR_NUM" --force
echo "generated=true" >> "$GITHUB_OUTPUT"
fi
python3 -c "
import re
with open('$PRDOC') as f:
c = f.read()
c = c.replace('crates: [ ]', 'crates:\n - name: forehead-core\n bump: patch\n - name: forehead-cli\n bump: patch')
with open('$PRDOC', 'w') as f:
f.write(c)
"

- name: Validate PRDoc
env:
CI: "true"
run: |
PRDOC="prdoc/pr_${{ github.event.pull_request.number }}.prdoc"
changelogger prdoc validate "$PRDOC"

- name: Validate Backport Rules
if: startsWith(github.base_ref, 'stable') || startsWith(github.base_ref, 'release')
run: |
PRDOC="prdoc/pr_${{ github.event.pull_request.number }}.prdoc"
changelogger prdoc validate --branch "${{ github.base_ref }}" "$PRDOC"
- name: Commit PRDoc
if: steps.generate.outputs.generated == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
Loading
Loading