Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: changelog in CI #157

Merged
merged 16 commits into from
Aug 22, 2024
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ name: CI

on:
workflow_dispatch:
workflow_call:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

Expand Down
136 changes: 90 additions & 46 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,75 +1,119 @@
name: Release

on:
# todo: allow this but should not build if the current HEAD is already tagger with nightly
#schedule:
# run every day
#- cron: 0 0 * * *
workflow_dispatch:
inputs:
is_nightly:
description: "Is nightly"
required: false
default: true
type: boolean

concurrency:
group: ${{ github.workflow }}
cancel-in-progress: true
permissions:
contents: write

env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CARGO_TERM_COLOR: always

jobs:
upload-artifacts:
uses: ./.github/workflows/upload_artifacts.yml
ci:
uses: ./.github/workflows/ci.yml

publish:
needs: upload-artifacts
runs-on: ubuntu-latest
commit-changes:
needs:
- ci

env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
runs-on: ubuntu-latest

permissions:
contents: write
outputs:
version: ${{ steps.identify.outputs.version }}

steps:
- uses: actions/checkout@v4
with:
# https://github.com/actions/checkout/issues/1471
fetch-tags: false
# must be after checkout because it will remove artifacts
- uses: actions/download-artifact@v4

- name: Prepare release on Github
run: |
# get the package version from Cargo.toml
echo "PKG_VERSION=$(cat VERSION)" >> $GITHUB_ENV
fetch-tags: true
fetch-depth: 0

# delete nightly release
gh release delete nightly --yes || true
git push --delete origin nightly || true
- uses: taiki-e/install-action@v2
with:
tool: changelog-gen

# in case is_nightly is not defined
- if: ${{ (github.event.inputs.is_nightly == 'true') || (github.event.inputs.is_nightly == '') }}
name: Setup options for nightly
- name: Set Github env
run: |
echo "TAG_NAME=nightly" >> $GITHUB_ENV
echo "PRERELEASE=--prerelease" >> $GITHUB_ENV
- if: ${{ github.event.inputs.is_nightly == 'false' }}
name: Setup options for a new release
echo "version="$(date +"%-y.%-m.%-d")"" >> $GITHUB_ENV
echo "release_date="$(date +"%Y-%m-%d")"" >> $GITHUB_ENV

- id: identify
run: |
echo "TAG_NAME=v${{ env.PKG_VERSION }}" >> $GITHUB_ENV
sed -i '/<release /s/version="[^"]*"/version="'"${{ env.version }}"'"/; /<release /s/date="[^"]*"/date="'"${{ env.release_date }}"'"/' "res/linux/metainfo.xml"
sed -i '/\[package.metadata.packager\]/,/^$/s/version = ".*"/version = "'"${{ env.version }}"'"/' "Cargo.toml"
echo ${{ env.version }} > VERSION

changelog-gen generate --exclude-unidentified
changelog-gen release --version ${{ env.version }}

echo "version=${{ env.version }}" >> $GITHUB_OUTPUT

- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore(changelog): automatic release generation (skip changelog) [skip ci]"
tagging_message: ${{ env.version }}

upload-artifacts:
needs:
- commit-changes
uses: ./.github/workflows/upload_artifacts.yml
with:
tag: ${{ needs.commit-changes.outputs.version }}

release-on-github:
needs:
- upload-artifacts
- commit-changes

runs-on: ubuntu-latest

steps:
# must be after checkout because it will remove artifacts
- uses: actions/download-artifact@v4

- uses: taiki-e/install-action@v2
with:
tool: changelog-gen

- name: Publish release
run: |
git tag ${{ env.TAG_NAME }}
git push origin --tags
changelog-gen -- show > RELEASE_CHANGELOG.md

# https://cli.github.com/manual/gh_release_create
gh release create ${{ env.TAG_NAME }} --title "${{ env.TAG_NAME }}" \
--verify-tag ${{ env.PRERELEASE }} --generate-notes --target $GITHUB_SHA \
gh release create ${{ needs.commit-changes.outputs.version }} --title ${{ needs.commit-changes.outputs.version }} \
--notes-file RELEASE_CHANGELOG.md --target $GITHUB_SHA \
./fan-control*/*

pr-to-flathub:
needs:
- commit-changes

runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: wiiznokes/io.github.wiiznokes.fan-control
ref: master

- uses: taiki-e/install-action@just

- run: |

git remote add upstream https://github.com/flathub/io.github.wiiznokes.fan-control
git fetch upstream
git rebase upstream/master
just

- name: Create Pull Request
uses: peter-evans/create-pull-request@v7-rc
with:
title: "Automatic Release"
base: master
branch: release
commit-message: "new release"
body: ""
delete-branch: true
branch-suffix: timestamp
token: ${{ secrets.PAT_FLATHUB }}
7 changes: 7 additions & 0 deletions .github/workflows/upload_artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ name: Upload Artifacts
on:
workflow_dispatch:
workflow_call:
inputs:
tag:
type: string
required: true

env:
CARGO_TERM_COLOR: always
Expand All @@ -12,6 +16,9 @@ jobs:
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ inputs.tag }}

- run: rustup update
- uses: taiki-e/install-action@just
- uses: Swatinem/rust-cache@v2
Expand Down
26 changes: 18 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
# Changelog

## [24.8.17]
## [Unreleased]

- update deps
- fix top bar color
## [24.8.22](https://github.com/wiiznokes/fan-control/releases/tag/24.8.22)

## [2024.7.30]
### Removed

- remove lazy_static dep in [7828ecb](https://github.com/wiiznokes/fan-control/commit/7828ecb8d1f6025ba911166814e8bd53c331b777) by [@wiiznokes](https://github.com/wiiznokes)
- rm once_cell in [a4c292e](https://github.com/wiiznokes/fan-control/commit/a4c292e9276bef8928710d8369939a6b2cc9cfcf) by [@wiiznokes](https://github.com/wiiznokes)

### Fixed

- small fixes in [4f62ac9](https://github.com/wiiznokes/fan-control/commit/4f62ac958d496ddb8b553019ecab0e5644c4c372) by [@wiiznokes](https://github.com/wiiznokes)

Full Changelog: https://github.com/wiiznokes/fan-control/compare/24.7.30...24.8.22

## [24.7.30]

- fix french translation
- hotfix: theme always dark
Expand Down Expand Up @@ -33,14 +43,14 @@
- new versioning
- update lhm

### Fixed

- udev rules

### Changed

- hardware generic

### Fixed

- udev rules

Many thanks to...

- @dawin64
Expand Down
Loading