aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/release.yml
blob: b34579ea19e692594bb7bb5b00cd2d6f0113f784 (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
name: Release
on:
  push: { branches: [master] }
  workflow_dispatch:

jobs:
  build-everything:
    uses: ./.github/workflows/build.yml
    secrets: inherit

  create-release:
    runs-on: ubuntu-latest
    needs: build-everything
    env: { GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" }

    steps:
      - name: Checkout code
        uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - name: Set Environment Variables
        run: |
          echo VERSION=`git describe --tags --abbrev=0 --match "v*" | tail -c +2` >> $GITHUB_ENV

      - name: Download Artifacts
        uses: actions/download-artifact@v4
        with:
          pattern: lpm.*
          path: artifacts
          merge-multiple: true

      - name: Create Release(s)
        run: |
          perl -pe 'last if $_ =~ m/^\s*#/ && $_ !~ m/#\s*$ENV{VERSION}/' < CHANGELOG.md | tail -n +2 > NOTES.md
          gh release delete -y continuous || true;
          gh release create -t 'Continuous Release' -F NOTES.md continuous ./artifacts/*
          if [[ `git tag --points-at HEAD v* | head -c 1` == "v" ]]; then
            gh release delete -y v$VERSION || true;
            gh release create -t v$VERSION -F NOTES.md v$VERSION ./artifacts/*
            gh release delete -y latest || true;
            gh release create -t latest -F NOTES.md latest ./artifacts/*
            git branch -f latest HEAD
            git tag -f latest
            git push -f origin refs/heads/latest
            git push -f origin refs/tags/latest
          fi
          git tag -f continuous
          git push -f origin refs/tags/continuous

      - name: Discord Notification
        env: { DISCORD_WEBHOOK: "${{ secrets.DISCORD_WEBHOOK }}" }
        run: |
          if [[ -n "$DISCORD_WEBHOOK" ]] && [[ `git tag --points-at HEAD v* | head -c 1` == "v" ]]; then
            perl -e 'use JSON qw(encode_json from_json); $/ = undef; print encode_json({ content => "## Lite XL Plugin Manager $ENV{VERSION} has been released!\nhttps://github.com/lite-xl/lite-xl-plugin-manager/releases/tag/v$ENV{VERSION}\n@release:lpm\n### Changes in $ENV{VERSION}:\n" . <> })' < NOTES.md |
              curl -H 'Content-Type:application/json' $DISCORD_WEBHOOK -X POST -d "$(</dev/stdin)"
          fi