Skip to content

Commit d68139c

Browse files
Update release.yml
1 parent 7b52262 commit d68139c

1 file changed

Lines changed: 99 additions & 12 deletions

File tree

.github/workflows/release.yml

Lines changed: 99 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,111 @@
1-
name: Release package to github
1+
name: Release packages to GitHub Packages
2+
23
on:
3-
release:
4-
types: [published]
4+
workflow_dispatch:
5+
56
permissions:
6-
contents: read
7+
contents: write
78
packages: write
9+
actions: write
10+
811
jobs:
9-
deploy:
12+
deploy-video-typescript-uploader:
1013
runs-on: ubuntu-latest
14+
outputs:
15+
VERSION: ${{ steps.version.outputs.VERSION }}
1116
steps:
12-
- uses: actions/checkout@v2
13-
- name: Append to npmrc
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
with:
20+
repository: fiddle-tools/api.video-typescript-uploader
21+
token: ${{ secrets.PACKAGES_UPLOAD_PAT }}
22+
23+
- name: Set up Node.js
24+
uses: actions/setup-node@v3
25+
with:
26+
node-version: 16
27+
registry-url: 'https://npm.pkg.github.com'
28+
29+
- name: Install dependencies
30+
run: npm install --no-save
31+
32+
- name: Configure Git
1433
run: |
15-
echo "//npm.pkg.github.com/:_authToken=$PACKAGES_UPLOAD_PAT" >> .npmrc
34+
git config --global user.email "github-actions@github.com"
35+
git config --global user.name "github-actions"
36+
37+
- name: Auto Increment Version
38+
id: version
39+
run: |
40+
NEW_VERSION=$(npm version patch -m "Bump version to %s [skip ci]" | sed 's/^v//')
41+
echo "VERSION=$NEW_VERSION" >> $GITHUB_ENV
42+
echo "VERSION=$NEW_VERSION" >> $GITHUB_OUTPUT
43+
git push origin main --follow-tags
1644
env:
17-
PACKAGES_UPLOAD_PAT: ${{ secrets.PACKAGES_UPLOAD_PAT }}
18-
- uses: actions/setup-node@v2
45+
NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_UPLOAD_PAT }}
46+
47+
- name: Create GitHub Release
48+
uses: actions/create-release@v1
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1951
with:
52+
tag_name: v${{ env.VERSION }}
53+
release_name: Release v${{ env.VERSION }}
54+
draft: false
55+
prerelease: false
56+
57+
- name: Publish package
58+
run: npm publish --registry=https://npm.pkg.github.com --access public
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_UPLOAD_PAT }}
61+
62+
Update-video-typescript-uploader-Dependency-In-video-typescript-media-recorder:
63+
needs: deploy-video-typescript-uploader
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Checkout repository
67+
uses: actions/checkout@v3
68+
with:
69+
repository: fiddle-tools/api.video-typescript-media-recorder
70+
token: ${{ secrets.PACKAGES_UPLOAD_PAT }}
71+
72+
- name: Set up Node.js
73+
uses: actions/setup-node@v3
74+
with:
75+
node-version: 16
2076
registry-url: 'https://npm.pkg.github.com'
21-
- run: npm install --no-save
22-
- run: npm publish
77+
scope: '@fiddle-tools'
78+
79+
- name: Authenticate npm
80+
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.PACKAGES_UPLOAD_PAT }}" > ~/.npmrc
81+
82+
- name: Install dependencies
83+
run: npm install --no-save
84+
env:
85+
NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_UPLOAD_PAT }}
86+
87+
- name: Configure Git
88+
run: |
89+
git config --global user.email "github-actions@github.com"
90+
git config --global user.name "github-actions"
91+
92+
- name: Update package.json with latest video-typescript-uploader version
93+
run: |
94+
jq --arg ver "${{ needs.deploy-video-typescript-uploader.outputs.VERSION }}" '.dependencies["@fiddle-tools/video-uploader"]=$ver' package.json > package.tmp.json
95+
mv package.tmp.json package.json
96+
97+
- name: Commit and push updated package.json
98+
run: |
99+
git add package.json
100+
git commit -m "chore: update video-typescript-uploader dependency to v${{ needs.deploy-video-typescript-uploader.outputs.VERSION }} [skip ci]"
101+
git push origin main
23102
env:
24103
NODE_AUTH_TOKEN: ${{ secrets.PACKAGES_UPLOAD_PAT }}
104+
105+
- name: Trigger workflow in api.video-typescript-media-recorder repo
106+
run: |
107+
curl -X POST -H "Accept: application/vnd.github.v3+json" \
108+
-H "Authorization: Bearer ${{ secrets.PACKAGES_UPLOAD_PAT }}" \
109+
-H "Content-Type: application/json" \
110+
https://api.github.com/repos/fiddle-tools/api.video-typescript-media-recorder/actions/workflows/release.yml/dispatches \
111+
-d '{"ref": "main"}'

0 commit comments

Comments
 (0)