deployer/.github/workflows/release.yml
2023-04-05 11:22:42 +02:00

71 lines
2.2 KiB
YAML

name: release
on:
release:
types:
- created
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install fx
run: go install github.com/antonmedv/fx@latest
- name: Get version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Build phar
run: php -d phar.readonly=0 bin/build -v"$RELEASE_VERSION"
- name: Upload phar
run: |
export PATH=${PATH}:`go env GOPATH`/bin
export RELEASE_ID=$(curl --fail-with-body -L \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
https://api.github.com/repos/deployphp/deployer/releases \
| fx ".find(x=> x.tag_name == 'v${RELEASE_VERSION}').id")
curl --fail-with-body -L \
-X POST \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/deployphp/deployer/releases/${RELEASE_ID}/assets?name=deployer.phar" \
--data-binary "@deployer.phar"
env:
GITHUB_TOKEN: ${{ secrets.MY_GITHUB_TOKEN_FOR_UPLOADING_RELEASES }}
- name: Add deployer.phar
shell: bash
run: |
set -x
git checkout -b dist
mv deployer.phar dep
chmod +x dep
git add -f dep
- name: Remove obsolete files & dirs
shell: bash
run: |
set -x
git rm -r .github/ bin/ docs/ tests/ *.lock *.yaml *.xml *.neon
- name: Update composer.json
shell: bash
run: |
set -x
cat composer.json | jq 'del(.autoload) | del(.scripts) | del(.require) | del(."require-dev") | setpath(["bin"]; "dep")' > composer-new.json
mv composer-new.json composer.json
git add composer.json
- name: Push release tag
shell: bash
run: |
set -x
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions"
git commit -m "Deployer $RELEASE_VERSION"
git tag "v$RELEASE_VERSION" --force
git push origin "v$RELEASE_VERSION" --force