From 0b6b191ea50c13fac6f49fe9664804be0eed553b Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 13:08:36 +0800 Subject: [PATCH 01/19] Add release job --- .github/workflows/release.yml | 124 ++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..3b9047c --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,124 @@ +name: Update Version and Create Release + +on: + push: + branches: + - master # monitor changes only in the master branch + paths: + - metadata.sh # monitor changes to the metadata.sh file + +permissions: + contents: write + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - name: Check out the code + id: checkout + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Source metadata.sh and export variables + id: get_version + run: | + source metadata.sh + echo "VERSION=${VERSION}" + echo "version=${VERSION}" >> ${GITHUB_OUTPUT} + + - name: Replace version in files + id: replace_version + run: | + # update version badge in markdown files + find . -type f -name "*.md" -exec sed -i "s/\(Version-\)[0-9]*\.[0-9]*\.[0-9]*\(-informational\)/\1${{ steps.get_version.outputs.version }}\2/g;s/\[Version: [0-9]*\.[0-9]*\.[0-9]*\]/\[Version: ${{ steps.get_version.outputs.version }}\]/g" {} + + + # update version in shell files + find . -type f -name "*.sh" -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_version.outputs.version }})/g" {} + + + # update version in binary files + find ./bin -type f -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_version.outputs.version }})/g" {} + + + # update version in config files + find ./doc -type f -name "*.config" -exec sed -i "s/version=.*/version=${{ steps.get_version.outputs.version }}/g" {} + + + # update version in service menu .desktop files + find ./ServiceMenus -type f -name "*.desktop" -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_version.outputs.version }})/g" {} + + + - name: Check if release exists + id: check_release + run: | + if [[ "$(gh release view "v${{ steps.get_version.outputs.version }}" 2>&1)" == "release not found" ]]; then + echo "Release v${{ steps.get_version.outputs.version }} has not been created." + exists=false + else + echo "Release v${{ steps.get_version.outputs.version }} already exists." + exists=true + fi + echo "exists=${exists}" >> ${GITHUB_OUTPUT} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check if files have changes + id: check_changes + run: | + git add . + if git diff --cached --exit-code >/dev/null; then + echo "Changes have not been made." + exists=false + else + echo "Changes have been made that are pending commit." + exists=true + fi + echo "exists=${exists}" >> ${GITHUB_OUTPUT} + + - name: Commit updated files + id: commit_changes + if: steps.check_changes.outputs.exists == 'true' + run: | + git config --local user.name "github-actions[bot]" + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git commit -m "Bump version to ${{ steps.get_version.outputs.version }}" + git push -u origin HEAD + + - name: Get previous release tag + id: get_prev_tag + if: steps.check_release.outputs.exists == 'false' + run: | + prev_tag=$(git describe --tags --abbrev=0 HEAD^ || echo "") + if [ -z "$prev_tag" ]; then + echo "No previous tag found, this might be the first release." + prev_tag="HEAD" # use HEAD to include all commits + else + echo "Previous version: ${prev_tag}" + fi + echo "prev_tag=${prev_tag}" >> ${GITHUB_OUTPUT} + + - name: Get commit messages since last release + id: get_commits + if: steps.check_release.outputs.exists == 'false' + run: | + commits="$(git log ${{ steps.get_prev_tag.outputs.prev_tag }}..HEAD --oneline | base64 -w 0)" + echo "Latest commits: ${commits}" + echo "commits=${commits}" >> ${GITHUB_OUTPUT} + + - name: Create GitHub Release + if: steps.check_release.outputs.exists == 'false' + id: create_release + run: | + # determine main branch + main_branch=$(git remote show origin | awk '/HEAD branch/ {print $NF}') + # decode the commit messages + decoded_commits=$(echo "${{ steps.get_commits.outputs.commits }}" | base64 --decode) + # prepare notes + release_notes="Release v${{ steps.get_version.outputs.version }}.\n\n**Changes**:\n\n${decoded_commits}" + + # create release + gh release create "v${{ steps.get_version.outputs.version }}" \ + --title "v${{ steps.get_version.outputs.version }}" \ + --notes "$(echo -e "${release_notes}")" \ + --target "${main_branch}" \ + --generate-notes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From cf6c5245eb3a221c854afb49986021508135adc8 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 13:34:45 +0800 Subject: [PATCH 02/19] Update version log --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3b9047c..f33b73a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: id: get_version run: | source metadata.sh - echo "VERSION=${VERSION}" + echo "Current version: ${VERSION}" echo "version=${VERSION}" >> ${GITHUB_OUTPUT} - name: Replace version in files From 840c2e70984bd493526fc4c473d7f5614089c252 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 18:39:00 +0800 Subject: [PATCH 03/19] Move id --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index f33b73a..14ead6a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -104,8 +104,8 @@ jobs: echo "commits=${commits}" >> ${GITHUB_OUTPUT} - name: Create GitHub Release - if: steps.check_release.outputs.exists == 'false' id: create_release + if: steps.check_release.outputs.exists == 'false' run: | # determine main branch main_branch=$(git remote show origin | awk '/HEAD branch/ {print $NF}') From a1c627e8000cba682665eee1af936223b073bb20 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 18:39:19 +0800 Subject: [PATCH 04/19] Update name and id --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 14ead6a..3953ea2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -28,8 +28,8 @@ jobs: echo "Current version: ${VERSION}" echo "version=${VERSION}" >> ${GITHUB_OUTPUT} - - name: Replace version in files - id: replace_version + - name: Update version in source code + id: update_version run: | # update version badge in markdown files find . -type f -name "*.md" -exec sed -i "s/\(Version-\)[0-9]*\.[0-9]*\.[0-9]*\(-informational\)/\1${{ steps.get_version.outputs.version }}\2/g;s/\[Version: [0-9]*\.[0-9]*\.[0-9]*\]/\[Version: ${{ steps.get_version.outputs.version }}\]/g" {} + From 62fceec7fefda73ab28561a2044bb93c70465597 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 18:52:33 +0800 Subject: [PATCH 05/19] Update step name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3953ea2..5d98a32 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: with: fetch-depth: 0 - - name: Source metadata.sh and export variables + - name: Source metadata file and export variables id: get_version run: | source metadata.sh From b801c5714e19ecbe7bab6c9645ed17a037effe33 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 18:52:46 +0800 Subject: [PATCH 06/19] Exit if required variable not set --- .github/workflows/release.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5d98a32..9c3ed7b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,9 +24,23 @@ jobs: - name: Source metadata file and export variables id: get_version run: | - source metadata.sh - echo "Current version: ${VERSION}" - echo "version=${VERSION}" >> ${GITHUB_OUTPUT} + # set metadata file name + metadata_file="metadata.sh" + # set version variable + version_var="VERSION" + + # source values from metadata file + source "${metadata_file}" + + # ensure version is set + if [ -z "${!version_var}" ]; then + echo "Error: \${${version_var}} is not set in the ${metadata_file} file" >&2 + exit 1 + fi + + # export result to output + echo "Current version: ${!version_var}" + echo "version=${!version_var}" >> ${GITHUB_OUTPUT} - name: Update version in source code id: update_version From 85f7e23435a6412951b5a772042073f42be65b31 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 18:53:05 +0800 Subject: [PATCH 07/19] Minor update to structure and add comments --- .github/workflows/release.yml | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9c3ed7b..33bd3e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -63,6 +63,7 @@ jobs: - name: Check if release exists id: check_release run: | + # check if release of current version exists if [[ "$(gh release view "v${{ steps.get_version.outputs.version }}" 2>&1)" == "release not found" ]]; then echo "Release v${{ steps.get_version.outputs.version }} has not been created." exists=false @@ -70,6 +71,8 @@ jobs: echo "Release v${{ steps.get_version.outputs.version }} already exists." exists=true fi + + # export result to output echo "exists=${exists}" >> ${GITHUB_OUTPUT} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -77,7 +80,10 @@ jobs: - name: Check if files have changes id: check_changes run: | + # add local files git add . + + # determine if changes were made if git diff --cached --exit-code >/dev/null; then echo "Changes have not been made." exists=false @@ -85,35 +91,49 @@ jobs: echo "Changes have been made that are pending commit." exists=true fi + + # export result to output echo "exists=${exists}" >> ${GITHUB_OUTPUT} - name: Commit updated files id: commit_changes if: steps.check_changes.outputs.exists == 'true' run: | + # configure git user git config --local user.name "github-actions[bot]" git config --local user.email "github-actions[bot]@users.noreply.github.com" + + # commit changes git commit -m "Bump version to ${{ steps.get_version.outputs.version }}" + + # push changes to current remote branch git push -u origin HEAD - name: Get previous release tag id: get_prev_tag if: steps.check_release.outputs.exists == 'false' run: | + # determine previous tag prev_tag=$(git describe --tags --abbrev=0 HEAD^ || echo "") - if [ -z "$prev_tag" ]; then + + # check if previous tag exists + if [ -z "${prev_tag}" ]; then echo "No previous tag found, this might be the first release." prev_tag="HEAD" # use HEAD to include all commits - else - echo "Previous version: ${prev_tag}" fi + + # export result to output + echo "Previous version: ${prev_tag}" echo "prev_tag=${prev_tag}" >> ${GITHUB_OUTPUT} - name: Get commit messages since last release id: get_commits if: steps.check_release.outputs.exists == 'false' run: | + # get commits between versions commits="$(git log ${{ steps.get_prev_tag.outputs.prev_tag }}..HEAD --oneline | base64 -w 0)" + + # export result to output echo "Latest commits: ${commits}" echo "commits=${commits}" >> ${GITHUB_OUTPUT} @@ -125,7 +145,7 @@ jobs: main_branch=$(git remote show origin | awk '/HEAD branch/ {print $NF}') # decode the commit messages decoded_commits=$(echo "${{ steps.get_commits.outputs.commits }}" | base64 --decode) - # prepare notes + # prepare release notes release_notes="Release v${{ steps.get_version.outputs.version }}.\n\n**Changes**:\n\n${decoded_commits}" # create release From 7c7bfc396ed1f2964908654bc86b1b40f812ec16 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 18:55:11 +0800 Subject: [PATCH 08/19] Reorder check_release step --- .github/workflows/release.yml | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 33bd3e3..cd13ef8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -60,23 +60,6 @@ jobs: # update version in service menu .desktop files find ./ServiceMenus -type f -name "*.desktop" -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_version.outputs.version }})/g" {} + - - name: Check if release exists - id: check_release - run: | - # check if release of current version exists - if [[ "$(gh release view "v${{ steps.get_version.outputs.version }}" 2>&1)" == "release not found" ]]; then - echo "Release v${{ steps.get_version.outputs.version }} has not been created." - exists=false - else - echo "Release v${{ steps.get_version.outputs.version }} already exists." - exists=true - fi - - # export result to output - echo "exists=${exists}" >> ${GITHUB_OUTPUT} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Check if files have changes id: check_changes run: | @@ -109,6 +92,23 @@ jobs: # push changes to current remote branch git push -u origin HEAD + - name: Check if release exists + id: check_release + run: | + # check if release of current version exists + if [[ "$(gh release view "v${{ steps.get_version.outputs.version }}" 2>&1)" == "release not found" ]]; then + echo "Release v${{ steps.get_version.outputs.version }} has not been created." + exists=false + else + echo "Release v${{ steps.get_version.outputs.version }} already exists." + exists=true + fi + + # export result to output + echo "exists=${exists}" >> ${GITHUB_OUTPUT} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get previous release tag id: get_prev_tag if: steps.check_release.outputs.exists == 'false' From 58de855a8c85ea4cbc1ab0db6aa7774851229f50 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 19:40:47 +0800 Subject: [PATCH 09/19] Add step to package assets into archive --- .github/workflows/release.yml | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index cd13ef8..a21a5ea 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -156,3 +156,19 @@ jobs: --generate-notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Package assets into archive + id: package_asset + if: steps.check_release.outputs.exists == 'false' + run: | + # set package values + name="kde-service-menu-reimage" + version="${{ steps.get_version.outputs.version }}" + arch="all" + asset="${name}_${version}_${arch}.tar.gz" + + # package required assets into a tar.gz file + tar -czvf "${asset}" bin doc ServiceMenus *.sh README.md + + # export asset path + echo "asset=${asset}" >> ${GITHUB_OUTPUT} From 47ba1fceb3ee2fe13ff851c3e084e0776f068a7d Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 23:04:29 +0800 Subject: [PATCH 10/19] Update metadata file name --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a21a5ea..3df24a2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,9 +3,9 @@ name: Update Version and Create Release on: push: branches: - - master # monitor changes only in the master branch + - master # monitor changes only in the master branch paths: - - metadata.sh # monitor changes to the metadata.sh file + - doc/package.conf # monitor changes to the package metadata file permissions: contents: write From e1dddb9f4bbbf31d564ec73d5deea226210788bd Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 23:04:38 +0800 Subject: [PATCH 11/19] Add METADATA_FILE env var --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3df24a2..be045ca 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,6 +10,9 @@ on: permissions: contents: write +env: + METADATA_FILE: "doc/package.conf" + jobs: release: runs-on: ubuntu-latest From 3af91dba3d92ee9b1462761a89f646ace326619e Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 23:05:06 +0800 Subject: [PATCH 12/19] Expore required vars from metadata to output --- .github/workflows/release.yml | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index be045ca..8d117e0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,23 +27,22 @@ jobs: - name: Source metadata file and export variables id: get_version run: | - # set metadata file name - metadata_file="metadata.sh" - # set version variable - version_var="VERSION" + # set required variables + required_vars=("namespace" "version" "arch") # source values from metadata file - source "${metadata_file}" - - # ensure version is set - if [ -z "${!version_var}" ]; then - echo "Error: \${${version_var}} is not set in the ${metadata_file} file" >&2 - exit 1 - fi - - # export result to output - echo "Current version: ${!version_var}" - echo "version=${!version_var}" >> ${GITHUB_OUTPUT} + source "${METADATA_FILE}" + + for var in "${required_vars[@]}"; do + # ensure variable is set + key="__${var}__" + if [ -z "${!key}" ]; then + echo "ERROR: Required variable \"${key}\" was not set successfully." + exit 1 + fi + # export variable to output + echo "${var}=${!key}" | tee -a ${GITHUB_OUTPUT} + done - name: Update version in source code id: update_version From 88ef6ff298dce6cb8c2a021941f0ab8913afea30 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 23:05:48 +0800 Subject: [PATCH 13/19] Update step id --- .github/workflows/release.yml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8d117e0..3f2edb4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -25,7 +25,7 @@ jobs: fetch-depth: 0 - name: Source metadata file and export variables - id: get_version + id: get_metadata run: | # set required variables required_vars=("namespace" "version" "arch") @@ -48,19 +48,19 @@ jobs: id: update_version run: | # update version badge in markdown files - find . -type f -name "*.md" -exec sed -i "s/\(Version-\)[0-9]*\.[0-9]*\.[0-9]*\(-informational\)/\1${{ steps.get_version.outputs.version }}\2/g;s/\[Version: [0-9]*\.[0-9]*\.[0-9]*\]/\[Version: ${{ steps.get_version.outputs.version }}\]/g" {} + + find . -type f -name "*.md" -exec sed -i "s/\(Version-\)[0-9]*\.[0-9]*\.[0-9]*\(-informational\)/\1${{ steps.get_metadata.outputs.version }}\2/g;s/\[Version: [0-9]*\.[0-9]*\.[0-9]*\]/\[Version: ${{ steps.get_metadata.outputs.version }}\]/g" {} + # update version in shell files - find . -type f -name "*.sh" -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_version.outputs.version }})/g" {} + + find . -type f -name "*.sh" -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_metadata.outputs.version }})/g" {} + # update version in binary files - find ./bin -type f -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_version.outputs.version }})/g" {} + + find ./bin -type f -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_metadata.outputs.version }})/g" {} + # update version in config files - find ./doc -type f -name "*.config" -exec sed -i "s/version=.*/version=${{ steps.get_version.outputs.version }}/g" {} + + find ./doc -type f -name "*.config" -exec sed -i "s/version=.*/version=${{ steps.get_metadata.outputs.version }}/g" {} + # update version in service menu .desktop files - find ./ServiceMenus -type f -name "*.desktop" -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_version.outputs.version }})/g" {} + + find ./ServiceMenus -type f -name "*.desktop" -exec sed -i -E "s/kde-service-menu-reimage \(version [0-9]+\.[0-9]+(\.[0-9]+)?\)/kde-service-menu-reimage (version ${{ steps.get_metadata.outputs.version }})/g" {} + - name: Check if files have changes id: check_changes @@ -89,7 +89,7 @@ jobs: git config --local user.email "github-actions[bot]@users.noreply.github.com" # commit changes - git commit -m "Bump version to ${{ steps.get_version.outputs.version }}" + git commit -m "Bump version to ${{ steps.get_metadata.outputs.version }}" # push changes to current remote branch git push -u origin HEAD @@ -98,11 +98,11 @@ jobs: id: check_release run: | # check if release of current version exists - if [[ "$(gh release view "v${{ steps.get_version.outputs.version }}" 2>&1)" == "release not found" ]]; then - echo "Release v${{ steps.get_version.outputs.version }} has not been created." + if [[ "$(gh release view "v${{ steps.get_metadata.outputs.version }}" 2>&1)" == "release not found" ]]; then + echo "Release v${{ steps.get_metadata.outputs.version }} has not been created." exists=false else - echo "Release v${{ steps.get_version.outputs.version }} already exists." + echo "Release v${{ steps.get_metadata.outputs.version }} already exists." exists=true fi @@ -148,11 +148,11 @@ jobs: # decode the commit messages decoded_commits=$(echo "${{ steps.get_commits.outputs.commits }}" | base64 --decode) # prepare release notes - release_notes="Release v${{ steps.get_version.outputs.version }}.\n\n**Changes**:\n\n${decoded_commits}" + release_notes="Release v${{ steps.get_metadata.outputs.version }}.\n\n**Changes**:\n\n${decoded_commits}" # create release - gh release create "v${{ steps.get_version.outputs.version }}" \ - --title "v${{ steps.get_version.outputs.version }}" \ + gh release create "v${{ steps.get_metadata.outputs.version }}" \ + --title "v${{ steps.get_metadata.outputs.version }}" \ --notes "$(echo -e "${release_notes}")" \ --target "${main_branch}" \ --generate-notes @@ -165,7 +165,7 @@ jobs: run: | # set package values name="kde-service-menu-reimage" - version="${{ steps.get_version.outputs.version }}" + version="${{ steps.get_metadata.outputs.version }}" arch="all" asset="${name}_${version}_${arch}.tar.gz" From 6ba4bd2a995b89c2337b16963dea2333b3b6b442 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 23:06:35 +0800 Subject: [PATCH 14/19] Get values from metadata --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3f2edb4..a204f3c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -164,9 +164,9 @@ jobs: if: steps.check_release.outputs.exists == 'false' run: | # set package values - name="kde-service-menu-reimage" + name="${{ steps.get_metadata.outputs.namespace }}" version="${{ steps.get_metadata.outputs.version }}" - arch="all" + arch="${{ steps.get_metadata.outputs.arch }}" asset="${name}_${version}_${arch}.tar.gz" # package required assets into a tar.gz file From e4112dcee9a0f1fb513c78c90468beb67761e0ba Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Fri, 23 Aug 2024 23:06:50 +0800 Subject: [PATCH 15/19] Add package metadata --- doc/package.conf | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 doc/package.conf diff --git a/doc/package.conf b/doc/package.conf new file mode 100644 index 0000000..11a17e5 --- /dev/null +++ b/doc/package.conf @@ -0,0 +1,12 @@ +__name__="kde-service-menu-reimage" +__namespace__="kde-service-menu-reimage" +__description__="Manipulate images e their metadata" +__version__="2.6.0" +__arch__=("any") +__url__="https://github.com/irfanhakim-as/${__namespace__}" +__license__=("GPL-3.0+") +__depends__=("dolphin" "imagemagick" "kdialog") +__opt_depends__=("jhead") +__author__="Irfan Hakim" +__author_email__="irfanhakim.as@yahoo.com" +__author_url__="https://github.com/irfanhakim-as" \ No newline at end of file From f60ad35320835d82efffd9b39721d7e04f052e2c Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Mon, 26 Aug 2024 13:32:49 +0800 Subject: [PATCH 16/19] Reorder package_asset step --- .github/workflows/release.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a204f3c..916ed1a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -139,6 +139,22 @@ jobs: echo "Latest commits: ${commits}" echo "commits=${commits}" >> ${GITHUB_OUTPUT} + - name: Package assets into archive + id: package_asset + if: steps.check_release.outputs.exists == 'false' + run: | + # set package values + name="${{ steps.get_metadata.outputs.namespace }}" + version="${{ steps.get_metadata.outputs.version }}" + arch="${{ steps.get_metadata.outputs.arch }}" + asset="${name}_${version}_${arch}.tar.gz" + + # package required assets into a tar.gz file + tar -czvf "${asset}" bin doc ServiceMenus *.sh README.md + + # export asset path + echo "asset=${asset}" >> ${GITHUB_OUTPUT} + - name: Create GitHub Release id: create_release if: steps.check_release.outputs.exists == 'false' @@ -158,19 +174,3 @@ jobs: --generate-notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Package assets into archive - id: package_asset - if: steps.check_release.outputs.exists == 'false' - run: | - # set package values - name="${{ steps.get_metadata.outputs.namespace }}" - version="${{ steps.get_metadata.outputs.version }}" - arch="${{ steps.get_metadata.outputs.arch }}" - asset="${name}_${version}_${arch}.tar.gz" - - # package required assets into a tar.gz file - tar -czvf "${asset}" bin doc ServiceMenus *.sh README.md - - # export asset path - echo "asset=${asset}" >> ${GITHUB_OUTPUT} From d80c859ec7b50b3a86c01d046aee1546feb8e6f5 Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Mon, 26 Aug 2024 13:33:21 +0800 Subject: [PATCH 17/19] Change step condition --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 916ed1a..e0740f2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -157,7 +157,7 @@ jobs: - name: Create GitHub Release id: create_release - if: steps.check_release.outputs.exists == 'false' + if: steps.package_asset.conclusion == 'success' run: | # determine main branch main_branch=$(git remote show origin | awk '/HEAD branch/ {print $NF}') From 9149016b961896b5c018570c0f894194710461dd Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Mon, 26 Aug 2024 13:33:32 +0800 Subject: [PATCH 18/19] Add step to upload asset to release --- .github/workflows/release.yml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e0740f2..fa1ca88 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -174,3 +174,12 @@ jobs: --generate-notes env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Upload assets to release + id: upload_asset + if: steps.package_asset.conclusion == 'success' && steps.create_release.conclusion == 'success' + run: | + # upload asset to the GitHub release + gh release upload "v${{ steps.get_metadata.outputs.version }}" "${{ steps.package_asset.outputs.asset }}" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From fa06d16d15748f118ef4d758fb39d415f027bdef Mon Sep 17 00:00:00 2001 From: Irfan Hakim Date: Mon, 26 Aug 2024 13:34:25 +0800 Subject: [PATCH 19/19] Update step name --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index fa1ca88..b5a23e3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -155,7 +155,7 @@ jobs: # export asset path echo "asset=${asset}" >> ${GITHUB_OUTPUT} - - name: Create GitHub Release + - name: Create GitHub release id: create_release if: steps.package_asset.conclusion == 'success' run: |