-
Notifications
You must be signed in to change notification settings - Fork 32
86 lines (71 loc) · 2.42 KB
/
ci.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
name: ci
on: push
jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 16.x
- run: npm install
- run: npm run test
# run only on semantic version tag
release:
needs: test
# if: startsWith(github.ref, 'refs/tags/v') && contains(github.ref, '.')
runs-on: ubuntu-latest
strategy:
fail-fast: true
steps:
- name: checkout
uses: actions/checkout@v4
# # GITHUB_ENV operates like a .env file
# - name: extract version
# run: |
# VERSION=${GITHUB_REF#refs/tags/}
# CLEAN_VERSION=${VERSION#v}
# echo "VERSION=$VERSION" >> $GITHUB_ENV
# echo "CLEAN_VERSION=$CLEAN_VERSION" >> $GITHUB_ENV
- name: node
uses: actions/setup-node@v4
with:
node-version: 16.x
- name: npm install
run: npm install
- name: dist
run: |
mkdir -p dist
- name: pack
run: npx [email protected] pack tarballs
- name: extract sha
id: extract_sha
run: |
# list files in dist directory
ls dist/
# extract version and SHA from the filename
FILENAME=$(ls dist/ | grep 'dotenv-vault-v.*-linux-x64.tar.gz' | head -n 1)
echo "extracted filename: $FILENAME"
VERSION=$(echo $FILENAME | grep -oP '(?<=dotenv-vault-v)[0-9.]+(?=-)')
SHA=$(echo $FILENAME | grep -oP '(?<=dotenv-vault-v[0-9.]+-)[^-]+(?=-linux-x64.tar.gz)')
echo "Extracted version: $VERSION"
echo "Extracted SHA: $SHA"
# Set outputs
echo "::set-output name=version::$VERSION"
echo "::set-output name=sha::$SHA"
- name: upload
run: npx [email protected] upload tarballs
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: promote
run: |
echo "${{ steps.upload }}"
PROMOTE_VERSION=$(echo ${{ steps.extract_sha.outputs.version }})
PROMOTE_SHA=$(echo ${{ steps.extract_sha.outputs.sha }})
npx [email protected] promote --version "$PROMOTE_VERSION" --sha "$PROMOTE_SHA"
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}