#[1]gnikyt feed [2]gnikyt Code ramblings. Shopify Github Action for versioning /* May 20, 2022 — 2.4KB */ Shopify recently updated their admin panel again and started to display the value of theme_version from config/settings_schema.json onto the theme listing page. Example (yellow highlight): [3]Shopify theme version example With our setup, all our client themes are connected to Github and every release gets tagged a version in SYMVER format. Depending on a developer or release manager to manually update config/settings_schema.json before releasing is not ideal; even with a process guide or release checklist, there is a chance it can be missed. We wanted an automated solution to update the theme_version value upon a tag being pushed to the master branch. We have come up with the following solution (.github/workflows/schema_version.yml): name: Schema version on: create: tags: [ v* ] jobs: replacement: runs-on: ubuntu-latest if: startsWith(github.ref, 'refs/tags/v') steps: - name: Checkout repo uses: actions/checkout@v2 - name: Update settings_schema.json run: | sed -i 's/"theme_version": ".*"/"theme_version": "''"/g' config/settin gs_schema.json - name: Commit changes uses: EndBug/add-and-commit@v9 with: push: origin HEAD:master default_author: github_actions message: "Updated settings_schema.json to version {% raw %}'${{ github .ref_name }}'{% endraw %}" add: config/settings_schema.json Now, anytime a version tag gets pushed to the master branch, the action will do the following: 1. Confirm the action to only run upon tagging; lines 3-5 2. Confirm the steps will only run if tagging happened; line 10 3. Checkout the repository; lines 12-13 4. Utilize sed to inline-replace the theme_version value to (removes the v); line 17 5. Commit the changes to the schema with a commit message containing the version; lines 19-25 [4]Shopify theme version output example Hopefully this is a helpful starting point for any other developers looking to do the same process. [5]MD | [6]TXT | [7]CC-4.0 This post is 2 years old and may contain outdated information. __________________________________________________________________ [8]Ty King Ty King A self-taught, seasoned, and versatile developer from Newfoundland. Crafting innovative solutions with care and expertise. See more [9]about me. [10]Github [11]LinkedIn [12]CV [13]RSS * * * * * * * * * * References Visible links: 1. /rss.xml 2. / 3. /assets/images/posts/shopify-versioning.png 4. /assets/images/posts/shopify-versioning-github.png 5. /shopify-github-action-versioning/index.md 6. /shopify-github-action-versioning/index.txt 7. https://creativecommons.org/licenses/by/4.0/ 8. /about 9. /about 10. https://github.com/gnikyt 11. https://linkedin.com/in/gnikyt 12. /assets/files/cv.pdf 13. /rss.xml Hidden links: 15. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-1 16. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-2 17. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-3 18. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-4 19. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-5 20. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-6 21. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-7 22. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-8 23. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-9 24. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-10 25. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-11 26. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-12 27. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-13 28. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-14 29. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-15 30. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-16 31. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-17 32. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-18 33. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-19 34. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-20 35. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-21 36. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-22 37. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-23 38. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-24 39. localhost/tmp/lynxXXXX11uxzO/L759639-1472TMP.html#cb1-25