Release #71
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: | |
schedule: | |
- cron: '0 0 * * 2' | |
jobs: | |
Diff: | |
runs-on: ubuntu-latest | |
outputs: | |
nb: ${{ steps.set-diff.outputs.nb }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
ref: 'stable' | |
- name: "Check diff" | |
id: set-diff | |
run: | | |
nb=0 #$(git diff --name-only stable..origin/main | grep -E "^tools|^workflows" | wc -l | tr -d " ") | |
echo "Find diff: ${nb}" | |
echo "nb=${nb}" >> "${GITHUB_OUTPUT}" | |
TagRaw: | |
needs: Diff | |
if: ${{ needs.Diff.outputs.nb > 0 }} | |
runs-on: ubuntu-latest | |
outputs: | |
tag: ${{ steps.tag_label.outputs.tag }} | |
changelog: ${{ steps.tag_raw.outputs.changelog }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: 'Bump version and push tag - dry run' | |
id: tag_raw | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
release_branches: stable | |
tag_prefix: | |
dry_run: true | |
- name: 'Format tag' | |
id: tag_label | |
env: | |
TAG: ${{ steps.tag_raw.outputs.new_tag }} | |
run: | | |
TAG=$(echo "$TAG" | cut -f1 -d "-") | |
echo "tag=$TAG" >> "$GITHUB_OUTPUT" | |
Changelog: | |
needs: [Diff, TagRaw] | |
if: ${{ needs.Diff.outputs.nb > 0 }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: 'Check file present' | |
run: | | |
[[ -f CHANGELOG.md ]] || touch CHANGELOG.md | |
- uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: 3 # Not needed with a .ruby-version file | |
bundler-cache: true # runs 'bundle install' and caches installed gems automatically | |
- name: 'Generate CHANGELOG' | |
env: | |
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
gem install github_changelog_generator | |
USER=$(echo "$GITHUB_REPOSITORY" | sed -e 's/\// /g' | awk '{print $1}') | |
PROJECT=$(echo "$GITHUB_REPOSITORY" | sed -e 's/\// /g' | awk '{print $2}') | |
echo "$USER $PROJECT" | |
github_changelog_generator --user "$USER" --project "$PROJECT" --no-unreleased | |
- name: 'Upload Artifact Changelog' | |
uses: actions/upload-artifact@v4 | |
with: | |
name: changelog-artifact | |
path: CHANGELOG.md | |
retention-days: 1 | |
Commit: | |
needs: [Changelog, Diff] | |
if: ${{ needs.Diff.outputs.nb > 0 }} | |
runs-on: ubuntu-latest | |
steps: | |
# Get Data | |
- name: 'Checkout' | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: 'Download Artifact Changelog' | |
uses: actions/download-artifact@v4 | |
with: | |
name: changelog-artifact | |
# Commit | |
- name: 'Commit files' | |
run: | | |
git config --local user.email "$GITHUB_EMAIL" | |
git config --local user.name "$GITHUB_USERNAME" | |
git add . | |
git commit -m "doc(changelog): update" | |
env: | |
GITHUB_USERNAME: guillaume-gricourt | |
GITHUB_EMAIL: [email protected] | |
- name: 'Push changes' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: 'Update main branch' | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main | |
Tag: | |
needs: [Commit, Diff, TagRaw] | |
if: ${{ needs.Diff.outputs.nb > 0 }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
fetch-depth: 0 | |
- name: 'Bump version and push tag' | |
id: tag | |
uses: mathieudutour/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
release_branches: stable | |
custom_tag: ${{ needs.TagRaw.outputs.tag }} | |
tag_prefix: | |
Release: | |
needs: [Diff, TagRaw, Tag] | |
if: ${{ needs.Diff.outputs.nb > 0 }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: 'Create Release' | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: ${{ needs.TagRaw.outputs.tag }} | |
body: ${{ needs.TagRaw.outputs.changelog }} |