-
Notifications
You must be signed in to change notification settings - Fork 0
140 lines (132 loc) · 5.01 KB
/
npm-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
# For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
name: npm-publish
on:
push:
branches:
- master # Change this to your default branch
jobs:
build:
runs-on: ubuntu-latest
continue-on-error: false
# outputs:
# status: ${{ steps.ID.conclusion }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
- run: npm ci
- name: Wait for CI action to succeed
uses: fountainhead/action-wait-for-check@297be350cf8393728ea4d4b39435c7d7ae167c93
# This is tagged version v1.1.0, but do not use version tags
# https://julienrenaux.fr/2019/12/20/github-actions-security-risk/
id: wait-for-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: ci-status
ref: ${{ github.event.pull_request.head.sha || github.sha }}
intervalSeconds: 20
timeoutSeconds: 240
- name: CI action build OK
if: steps.wait-for-build.outputs.conclusion == 'success'
run: exit 0
- name: CI action build FAIL
if: steps.wait-for-build.outputs.conclusion != 'success'
run: exit 1
test-version:
needs: build
runs-on: ubuntu-latest
outputs:
status: ${{ steps.check.outputs.changed || false }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
- name: Check if version has been updated
id: check
uses: EndBug/version-check@8240855b2dbd43fc1c3c628d7aa75cfa07b76ab4
# This is tagged version v2.1.2, but do not use version tags
# https://julienrenaux.fr/2019/12/20/github-actions-security-risk/
with:
diff-search: true
publish-npm:
needs: test-version
runs-on: ubuntu-latest
if: needs.test-version.outputs.status == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- name: Publish if version has been updated
uses: pascalgn/npm-publish-action@374314eadce0ca5353387666469a949f69414752
# This is tagged version v1.3.9, but do not use version tags
# https://julienrenaux.fr/2019/12/20/github-actions-security-risk/
with: # All of theses inputs are optional
tag_name: "v%s"
tag_message: "v%s"
commit_pattern: "^Release (\\S+)"
workspace: "."
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this as is, it's automatically generated
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} # You need to set this in your repo settings
publish-gpr:
needs: test-version
runs-on: ubuntu-latest
if: needs.test-version.outputs.status == 'true'
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
- name: Update package name
run: |
sudo npm install -g json
REGISTRY_NAME=`json registryNames.github -f package.json`
json -I -f package.json -e this.name=\"$REGISTRY_NAME\"
- name: Publishing new package
run: |
npm ci
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-aur:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup ssh key
run: |
mkdir "$HOME/.ssh/"
echo -e "${{ secrets.AUR_AUTH_KEY }}" > "$HOME/.ssh/aur"
sudo chmod 600 "$HOME/.ssh/aur"
ssh-keygen -y -f "$HOME/.ssh/aur" > "$HOME/.ssh/aur.pub"
sudo chmod 600 "$HOME/.ssh/aur.pub"
echo -e "Host aur.archlinux.org\n IdentityFile $HOME/.ssh/aur" > "$HOME/.ssh/config"
eval "$(ssh-agent -s)"
ssh-add "$HOME/.ssh/aur"
- name: Clone aur repository
run: |
ssh -o StrictHostKeyChecking=no aur@aur.archlinux.org uptime || echo ""
echo -e "[user]\nemail = theo.cousinet@epitech.eu\nname = Theo\n" > "$HOME/.gitconfig"
git clone --depth=1 ssh://aur@aur.archlinux.org/blih_cli-git.git
- name: Update PKGBUILD file # eg: v0.2.0-16-g13e7cc3 -> 0.2.0_16_g13e7cc3 -> update PKGBUILD file
run: |
PKGVER=`git show --format=\"%H\" --no-patch | git describe --tags | sed 's/v//' | sed 's/-/_/g'`
if [ -z "$PKGVER" ];then exit 1; fi;
cd blih_cli-git/
sed -Ei "s/pkgver=.*/pkgver=$PKGVER/" PKGBUILD
sed -Ei "s/pkgver = .*/pkgver = $PKGVER/" .SRCINFO
- name: Publishing new package
run: |
rm -rf .git/
cd blih_cli-git/
git add -A
git commit -m "github action auto update"
git push