diff options
author | Takase <20792268+takase1121@users.noreply.github.com> | 2024-12-02 12:45:18 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-12-01 23:45:18 -0500 |
commit | e6eb3bc53dfd3c912d3e6c0f75b17d2e057228ed (patch) | |
tree | 0a863ea2638b49c6fdc06d4ac2ef17c692b67d9d | |
parent | 32a7245c18adb166b8b2e3cb18e7f5b54f629c4d (diff) | |
download | lite-xl-plugin-manager-e6eb3bc53dfd3c912d3e6c0f75b17d2e057228ed.tar.gz lite-xl-plugin-manager-e6eb3bc53dfd3c912d3e6c0f75b17d2e057228ed.zip |
ci: run build and test on PR creation (#149)
-rw-r--r-- | .github/workflows/build.yml | 51 | ||||
-rw-r--r-- | .github/workflows/release.yml | 57 |
2 files changed, 60 insertions, 48 deletions
diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fc4c7e9..f7fdcf4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,7 +1,9 @@ name: CI on: - push: { branches: [master] } + push: + pull_request: { branches: ['*'] } workflow_dispatch: + workflow_call: jobs: build: @@ -140,50 +142,3 @@ jobs: path: ${{ env.BIN }} name: ${{ env.BIN }} - create-release: - runs-on: ubuntu-latest - needs: [build, build-macos] - 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 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..b34579e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,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 |