{"id":46393,"date":"2025-08-16T08:29:41","date_gmt":"2025-08-16T08:29:41","guid":{"rendered":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/?p=46393"},"modified":"2025-08-16T08:29:41","modified_gmt":"2025-08-16T08:29:41","slug":"github-action-to-create-a-release","status":"publish","type":"post","link":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/github-action-to-create-a-release\/","title":{"rendered":"GitHub Action to create a release"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">With this workflow in place, creating a new release is as simple as pushing a version tag to your repository. The GitHub Action takes care of everything else for you. It checks out your code, sets up Node.js (using the latest LTS version), and installs your project\u2019s dependencies if a package.json file is present. Once that\u2019s done, it runs your build process to prepare the project for distribution.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The workflow then collects the necessary files, ignoring anything listed in .distignore, and copies them into a clean dist directory. From there it creates a zip archive of your project and attaches it to a new GitHub Release. The entire process is fully automated, which means you no longer need to manually package or upload files every time you want to publish a new version. Simply tag your release, push it, and GitHub handles the rest.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Place it under \u201c.\/github\/workflows\/release.yml\u201d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code class=\"\">name: Build and Release\n\non:\n  push:\n    tags:\n      - '[0-9]+'  # Matches single-digit tags like 1, 2, 3, etc.\n      - '[0-9]+.[0-9]+'  # Matches tags like 1.0, 1.1, 2.0, etc.\n      - '[0-9]+.[0-9]+.[0-9]+'  # Matches tags like 1.0.0, 1.0.1, 2.0.0, etc.\n\njobs:\n  dist:\n    name: \"Build distribution release.\"\n    runs-on: ubuntu-latest\n\n    steps:\n      - name: \"Checks out the repository.\"\n        uses: \"actions\/checkout@v2\"\n\n      - name: \"Setup NodeJS.\"\n        uses: actions\/setup-node@v2\n        with:\n          node-version: '20'  # Use the latest LTS version of Node.js\n\n      - name: \"Install NPM dependencies\"\n        run: |\n          if [ -f package.json ]; then\n            npm install\n          fi\n\n      - name: \"Build release: Stable\"\n        run: |\n          if [ -f package.json ]; then\n            npm run build\n          fi\n\n      - name: \"Copy files to distribution directory excluding .distignore entries\"\n        run: |\n          if [ -f .distignore ]; then\n            rsync -a --delete --exclude-from='.distignore' .\/ dist\/\n          else\n            rsync -a --delete .\/ dist\/\n          fi\n\n      - name: \"Create a Release Archive\"\n        run: |\n          cd dist\n          zip -r ..\/test-2.zip .\n\n      - name: \"Debug: List Distribution Directory\"\n        run: ls -la dist\n\n      - name: \"Create a GitHub Release\"\n        uses: softprops\/action-gh-release@v1\n        with:\n          files: test-2.zip\n        env:\n          GITHUB_TOKEN: $ # Replase TEST_TOKEN with your token name<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>With this workflow in place, creating a new release is as simple as pushing a version tag to your repository. The GitHub Action takes care of everything else for you. It checks out your code, sets up Node.js (using the latest LTS version), and installs your project\u2019s dependencies if a package.json file is present. Once [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":46589,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"slim_seo":{"title":"GitHub Action to create a release - Code DPlugins","description":"With this workflow in place, creating a new release is as simple as pushing a version tag to your repository. The GitHub Action takes care of everything else fo"},"_slim_seo_primary_term_category":0,"_slim_seo_primary_term_post_tag":0,"footnotes":""},"categories":[105],"tags":[106,107,108],"dpc_library":[],"class_list":["post-46393","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-github","tag-actions","tag-build","tag-release"],"_links":{"self":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46393","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/comments?post=46393"}],"version-history":[{"count":0,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/posts\/46393\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media\/46589"}],"wp:attachment":[{"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/media?parent=46393"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/categories?post=46393"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/tags?post=46393"},{"taxonomy":"dpc_library","embeddable":true,"href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/code.dplugins.com\/wp-json\/wp\/v2\/dpc_library?post=46393"}],"curies":[{"name":"wp","href":"https:\/\/summer-heart-0930.chufeiyun1688.workers.dev:443\/https\/api.w.org\/{rel}","templated":true}]}}