summaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: 929dd121d2d3947e6316a6f09739d1b95536c63a (plain)
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
name: Release
on:
  push:
    branches:
      - master
  workflow_dispatch:
    branches:
      - master
jobs:
  run-tests:
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - name: "Install PHP dependencies"
        uses: php-actions/composer@v6

      - name: "Run tests"
        run: ./vendor/pestphp/pest/bin/pest

  build-zip:
    runs-on: ubuntu-latest
    depends-on: [run-tests]
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          fetch-depth: 0

      - uses: paulhatch/semantic-version@v4.0.2
        id: semver
        with:
          # The prefix to use to identify tags
          tag_prefix: "v"
          # A string which, if present in a git commit, indicates that a change represents a
          # major (breaking) change, supports regular expressions wrapped with '/'
          major_pattern: "(MAJOR)"
          # Same as above except indicating a minor change, supports regular expressions wrapped with '/'
          minor_pattern: "(MINOR)"
          # A string to determine the format of the version output
          format: "${major}.${minor}.${patch}"
          # If this is set to true, *every* commit will be treated as a new version.
          bump_each_commit: true

      - run: git log $(git describe --tags --abbrev=0)..HEAD --no-merges --oneline > new-in-this-release.log

      - name: Read git log
        id: package
        uses: juliangruber/read-file-action@v1
        with:
          path: ./new-in-this-release.log

      - name: "Create Release"
        id: create_release
        uses: actions/create-release@v1
        env:
          GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
        with:
          tag_name: ${{steps.semver.outputs.version_tag}}
          release_name: ${{steps.semver.outputs.version_tag}}
          body: ${{ steps.package.outputs.content }}
          draft: false
          prerelease: false

      - name: "Install PHP dependencies"
        uses: php-actions/composer@v6

      - name: "ZIP"
        uses: papeloto/action-zip@v1
        with:
          files: /
          dest: hird-${{steps.semver.outputs.version_tag}}.zip

      - name: "Publish"
        uses: actions/upload-artifact@v2-preview
        with:
          name: hird-${{steps.semver.outputs.version_tag}}.zip
          path: hird-${{steps.semver.outputs.version_tag}}.zip

      - name: "Upload"
        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: hird-${{steps.semver.outputs.version_tag}}.zip
          asset_name: hird-${{steps.semver.outputs.version_tag}}.zip
          asset_content_type: application/zip