-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (82 loc) · 2.63 KB
/
preview-workflow.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: Preview workflow
env:
PACKAGE_NAME: purge-backups
GIT_COMMITTER_EMAIL: bot@srnjak.com
GIT_COMMITTER_NAME: Srnjak bot
defaults:
run:
shell: bash -eo pipefail {0}
on:
push:
branches:
- develop
workflow_dispatch:
workflow_run:
workflows: [ "Merge master into develop" ]
types:
- completed
jobs:
preview-job:
if: >
!contains(github.event.head_commit.message, 'Release of version')
&& github.event.head_commit.message != 'Merge branch ''master'' into develop'
&& (
github.event_name == 'push' && github.ref == 'refs/heads/develop'
|| github.event.workflow_run.conclusion == 'success'
|| github.event.workflow_dispatch
)
runs-on: ubuntu-latest
container:
image: srnjak/debian-package-builder:latest
env:
GIT_SSH_VARIANT: ssh
steps:
- name: Set up Git identity
run: |
git config --global user.email "${{ env.GIT_COMMITTER_EMAIL }}"
git config --global user.name "${{ env.GIT_COMMITTER_NAME }}"
- name: Checkout code
uses: actions/checkout@v3
with:
ref: develop
- run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Set up version
id: version_step
run: |
VERSION=$(version-updater.sh $(pwd) --new-preview)
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "version=$VERSION"
- name: Prepare
run: |
builder.sh clean
builder.sh prepare -n "${{ env.PACKAGE_NAME }}"
- name: Package
run: |
builder.sh package -n "${{ env.PACKAGE_NAME }}" -o "${{ env.PACKAGE_NAME }}.deb"
- name: Deploy
run: |
builder.sh deploy \
-u "${{ vars.REPOSITORY_PREVIEW_USERNAME }}" \
-p "${{ secrets.REPOSITORY_PREVIEW_PASSWORD }}" \
-r "${{ vars.REPOSITORY_PREVIEW_URL }}" \
-n "${{ env.PACKAGE_NAME }}"
- name: Commit and tag release changes
run: |
VERSION=${{ steps.version_step.outputs.version }}
git add .
git commit -m "Release of version $VERSION"
TAG_NAME="v${VERSION//\~/-}"
git tag "$TAG_NAME"
git push origin develop
if ! git push origin --force "$TAG_NAME"; then
echo "Tag $TAG_NAME already exists."
fi
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- name: Upload release artifact
uses: actions/upload-artifact@v2
with:
name: Preview
path: target/${{ env.PACKAGE_NAME }}.deb
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}