1*290ea73dSAndreas Gohr# This workflow creates a new tag, builds the release archives and uploads them to GitHub and our server 2*290ea73dSAndreas Gohr# It is triggered by pushing to the stable branch, either manually or by merging a PR created by the 3*290ea73dSAndreas Gohr# release-preparation workflow 4*290ea73dSAndreas Gohr 5*290ea73dSAndreas Gohrname: "Release: Tag, Build & Deploy" 6*290ea73dSAndreas Gohron: 7*290ea73dSAndreas Gohr push: 8*290ea73dSAndreas Gohr branches: 9*290ea73dSAndreas Gohr - stable 10*290ea73dSAndreas Gohr 11*290ea73dSAndreas Gohrjobs: 12*290ea73dSAndreas Gohr 13*290ea73dSAndreas Gohr tag: 14*290ea73dSAndreas Gohr name: Tag Release 15*290ea73dSAndreas Gohr runs-on: ubuntu-latest 16*290ea73dSAndreas Gohr steps: 17*290ea73dSAndreas Gohr - name: Checkout 18*290ea73dSAndreas Gohr uses: actions/checkout@v3 19*290ea73dSAndreas Gohr 20*290ea73dSAndreas Gohr - name: Prepare Environment 21*290ea73dSAndreas Gohr run: | 22*290ea73dSAndreas Gohr php .github/release.php current >> $GITHUB_ENV 23*290ea73dSAndreas Gohr 24*290ea73dSAndreas Gohr - name: Check if a tag already exists 25*290ea73dSAndreas Gohr run: | 26*290ea73dSAndreas Gohr if git rev-parse "release-${{ env.current_version }}" >/dev/null 2>&1; then 27*290ea73dSAndreas Gohr echo "::error::Tag already exists, be sure to update the VERSION file for a hotfix" 28*290ea73dSAndreas Gohr exit 1 29*290ea73dSAndreas Gohr fi 30*290ea73dSAndreas Gohr 31*290ea73dSAndreas Gohr - name: Create tag 32*290ea73dSAndreas Gohr uses: actions/github-script@v6 33*290ea73dSAndreas Gohr with: 34*290ea73dSAndreas Gohr # a privileged token is needed here to create the (protected) tag 35*290ea73dSAndreas Gohr github-token: ${{ secrets.RELEASE_TOKEN }} 36*290ea73dSAndreas Gohr script: | 37*290ea73dSAndreas Gohr const {current_version} = process.env; 38*290ea73dSAndreas Gohr github.rest.git.createRef({ 39*290ea73dSAndreas Gohr owner: context.repo.owner, 40*290ea73dSAndreas Gohr repo: context.repo.repo, 41*290ea73dSAndreas Gohr ref: `refs/tags/release-${current_version}`, 42*290ea73dSAndreas Gohr sha: context.sha 43*290ea73dSAndreas Gohr }); 44*290ea73dSAndreas Gohr 45*290ea73dSAndreas Gohr build: 46*290ea73dSAndreas Gohr name: Build Release 47*290ea73dSAndreas Gohr needs: tag 48*290ea73dSAndreas Gohr runs-on: ubuntu-latest 49*290ea73dSAndreas Gohr steps: 50*290ea73dSAndreas Gohr - name: Checkout 51*290ea73dSAndreas Gohr uses: actions/checkout@v3 52*290ea73dSAndreas Gohr 53*290ea73dSAndreas Gohr - name: Prepare Environment 54*290ea73dSAndreas Gohr run: | 55*290ea73dSAndreas Gohr php .github/release.php current >> $GITHUB_ENV 56*290ea73dSAndreas Gohr 57*290ea73dSAndreas Gohr - name: Build Archives 58*290ea73dSAndreas Gohr run: | 59*290ea73dSAndreas Gohr for F in $(awk '/export-ignore/{print $1}' .gitattributes); do 60*290ea73dSAndreas Gohr rm -rf $F 61*290ea73dSAndreas Gohr done 62*290ea73dSAndreas Gohr mkdir -p data/pages/playground 63*290ea73dSAndreas Gohr echo "====== PlayGround ======" > data/pages/playground/playground.txt 64*290ea73dSAndreas Gohr cd .. 65*290ea73dSAndreas Gohr mv ${{ github.event.repository.name }} "dokuwiki-${{ env.current_file }}" 66*290ea73dSAndreas Gohr tar -czvf "dokuwiki-${{ env.current_file }}.tgz" dokuwiki-${{ env.current_file }} 67*290ea73dSAndreas Gohr zip -r "dokuwiki-${{ env.current_file }}.zip" dokuwiki-${{ env.current_file }} 68*290ea73dSAndreas Gohr rm -rf "dokuwiki-${{ env.current_file }}" 69*290ea73dSAndreas Gohr mkdir ${{ github.event.repository.name }} 70*290ea73dSAndreas Gohr mv "dokuwiki-${{ env.current_version }}.tgz" ${{ github.event.repository.name }}/ 71*290ea73dSAndreas Gohr mv "dokuwiki-${{ env.current_version }}.zip" ${{ github.event.repository.name }}/ 72*290ea73dSAndreas Gohr 73*290ea73dSAndreas Gohr - name: Release to Github 74*290ea73dSAndreas Gohr id: release 75*290ea73dSAndreas Gohr uses: softprops/action-gh-release@v1 76*290ea73dSAndreas Gohr with: 77*290ea73dSAndreas Gohr name: DokuWiki ${{ env.current_raw }} [${{ env.current_update }}] 78*290ea73dSAndreas Gohr tag_name: release-${{ env.current_version }} 79*290ea73dSAndreas Gohr files: | 80*290ea73dSAndreas Gohr dokuwiki-${{ env.current_file }}.tgz 81*290ea73dSAndreas Gohr dokuwiki-${{ env.current_file }}.zip 82*290ea73dSAndreas Gohr outputs: 83*290ea73dSAndreas Gohr version: ${{ env.current_version }} 84*290ea73dSAndreas Gohr file: ${{ env.current_file }} 85*290ea73dSAndreas Gohr url: ${{ steps.release.outputs.url }} 86*290ea73dSAndreas Gohr 87*290ea73dSAndreas Gohr deploy: 88*290ea73dSAndreas Gohr name: Deploy Release 89*290ea73dSAndreas Gohr needs: build 90*290ea73dSAndreas Gohr runs-on: ubuntu-latest 91*290ea73dSAndreas Gohr steps: 92*290ea73dSAndreas Gohr - name: Download 93*290ea73dSAndreas Gohr run: | 94*290ea73dSAndreas Gohr wget ${{ needs.build.outputs.url }}/dokuwiki-${{ needs.build.outputs.file }}.tgz 95*290ea73dSAndreas Gohr 96*290ea73dSAndreas Gohr - name: Setup SSH Key 97*290ea73dSAndreas Gohr uses: shimataro/ssh-key-action@v2 98*290ea73dSAndreas Gohr with: 99*290ea73dSAndreas Gohr key: ${{ secrets.SSH_PRIVATE_KEY }} 100*290ea73dSAndreas Gohr # generate with ssh-keyscan -H <server> 101*290ea73dSAndreas Gohr known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }} 102*290ea73dSAndreas Gohr 103*290ea73dSAndreas Gohr - name: Deploy to Server 104*290ea73dSAndreas Gohr run: | 105*290ea73dSAndreas Gohr scp "dokuwiki-${{ needs.build.outputs.file }}.tgz" ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:htdocs/src/dokuwiki/ 106*290ea73dSAndreas Gohr ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} "cd htdocs/src/dokuwiki/ && tar -xzvf dokuwiki-${{ needs.build.outputs.file }}.tgz" 107