bump version
v2.3.1
การกระทำของ GitHub นี้รับค่าของแท็กและส่งผ่านไปยังแอปพลิเคชันแทนที่เวอร์ชันคงที่ใน package.json โดยอัตโนมัติโดยไม่ต้องสร้างคอมมิวนิกใหม่และเปลี่ยนเวอร์ชันด้วยตนเอง
การกระทำนี้ใช้งานได้กับเหตุการณ์แบบพุชของ แท็ก ประเภท เท่านั้น
ตัวอย่าง:
on :
push :
tags :
- ' v[0-9]+.[0-9]+.[0-9]+ 'หากคุณใช้การกระทำนี้กับ worflow ที่ทำงานโดยไม่มีทริกเกอร์นี้ขั้นตอนนี้จะแตก
ในขณะนี้เพียงแค่สนับสนุน package.json ที่ต้องการมีอยู่ในโฟลเดอร์รูท
name : Deploy Package to NPM
on :
push :
tags :
- ' v[0-9]+.[0-9]+.[0-9]+ '
jobs :
publish_npm :
name : Publishing to NPM
runs-on : ubuntu-latest
permissions :
actions : write
contents : write
steps :
- uses : actions/checkout@v3
- name : Setup NodeJs
uses : actions/setup-node@v3
with :
node-version : x.y # Version that you want use here
registry-url : https://registry.npmjs.org/
- name : Install Packages
run : yarn
- name : Bump Version of package.json
uses : ramonpaolo/[email protected]
with :
tag : ${{ github.ref_name }} # Accessing the context and get the reference_name, that in this case, is the tag that you created(ex: v1.0.0)
commit : true
branch_to_push : ' main '
- name : Publish package to NPM
run : npm publish
env :
NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }} # NPM Token necessary to deploy packages on pipelines CI/CD | ชื่อ | คำอธิบาย | ที่จำเป็น | ค่าเริ่มต้น |
|---|---|---|---|
| ติดแท็ก | แท็กสร้างขึ้น (v.*.*.*) | true | "v1.0.0" |
| ให้สัญญา | ทุ่มเท | false | false |
| branch_to_push | สาขาไหนที่จะผลักดัน | false | "หลัก" |
| เส้นทาง | เส้นทางของ package.json | false | "./package.json" |
| ชื่อ | คำอธิบาย |
|---|---|
| แท็กที่แยกวิเคราะห์ | v1.0.0 (อินพุต) = 1.0.0 (เอาต์พุต) |