forked from Be-Secure/BeSman
-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (73 loc) · 2.66 KB
/
dopublish.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
name: Release BeSman
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- '*.*.*'
env:
BES_ARCHIVE_DOWNLOAD_REPO: "BeSman"
BESMAN_NAMESPACE: "asa1997"
BESMAN_VERSION: ${{ github.ref }}
jobs:
publish_artifacts:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set env for version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
- name: list
run: ls
- name: Copy and replace template files
run: |
cp scripts/tmpl/*.tmpl scripts/
file=scripts/get.besman.io.tmpl
sed -i "s/@BES_VERSION@/$BESMAN_VERSION/g" $file
sed -i "s/@BES_ARCHIVE_DOWNLOAD_REPO@/$BES_ARCHIVE_DOWNLOAD_REPO/g" $file
sed -i "s/@BES_NAMESPACE@/$BESMAN_NAMESPACE/g" $file
mv "$file" "${file//.tmpl/}"
- name: Setting up dir
run: mkdir -p build/tmp
- name: Generate artifacts
run: |
zip -rj ./build/tmp/besman-latest.zip ./dist/list.txt ./src/main/bash/besman-* ./src/main/bash/scripts/besman-* ./src/main/bash/commands/besman-*
cp ./build/tmp/besman-latest.zip ./build/tmp/besman-$RELEASE_VERSION.zip
mv ./scripts/get.besman.io ./build/tmp/
ls ./build/tmp/
- name: Commit artifacts to dist branch
run: |
git config --global user.name 'GitHub Action'
git config --global user.email 'action@github.com'
git fetch origin dist
git checkout -b dist origin/dist
mkdir -p dist
cp -r ./build/tmp/* ./dist/
git add ./dist/*
git commit -m "Release version $RELEASE_VERSION"
git push origin HEAD:dist
create_release:
needs: publish_artifacts
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
- name: Upload Release Asset
id: upload-release-asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/besman-latest.zip
asset_name: besman-latest.zip
asset_content_type: application/zip