|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [ released ] |
| 6 | + |
| 7 | +jobs: |
| 8 | + build: |
| 9 | + name: Upload Release Asset |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + packages: write |
| 13 | + contents: write |
| 14 | + env: |
| 15 | + PLUGIN: release-integration-template-go |
| 16 | + REGISTRY_URL: ghcr.io |
| 17 | + REGISTRY_ORG: digital-ai |
| 18 | + |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v2 |
| 21 | + - name: Set release version to environment |
| 22 | + run: | |
| 23 | + TAG=${{ github.ref_name }} |
| 24 | + echo "VERSION=${TAG#v}" >> $GITHUB_ENV |
| 25 | + |
| 26 | + - name: Write environment values to project.properties |
| 27 | + run: | |
| 28 | + sed -i "/PLUGIN=/ s/=.*/=${{ env.PLUGIN }}/" project.properties |
| 29 | + sed -i "/VERSION=/ s/=.*/=${{ env.VERSION }}/" project.properties |
| 30 | + sed -i "/REGISTRY_URL=/ s/=.*/=${{ env.REGISTRY_URL }}/" project.properties |
| 31 | + sed -i "/REGISTRY_ORG=/ s/=.*/=${{ env.REGISTRY_ORG }}/" project.properties |
| 32 | + |
| 33 | + - name: Build zip file |
| 34 | + run: sh build.sh |
| 35 | + |
| 36 | + - name: Get latest release |
| 37 | + id: get_release |
| 38 | + uses: bruceadams/get-release@v1.3.2 |
| 39 | + env: |
| 40 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 41 | + |
| 42 | + - name: Upload Release Asset |
| 43 | + id: upload-release-asset |
| 44 | + uses: actions/upload-release-asset@v1 |
| 45 | + env: |
| 46 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 47 | + with: |
| 48 | + upload_url: ${{ steps.get_release.outputs.upload_url }} |
| 49 | + asset_path: ${{ format('build/{0}-{1}.zip', env.PLUGIN, env.VERSION) }} |
| 50 | + asset_name: ${{ format('{0}-{1}.zip', env.PLUGIN, env.VERSION) }} |
| 51 | + asset_content_type: application/zip |
| 52 | + |
| 53 | + - name: Log in to Container registry |
| 54 | + uses: docker/login-action@v2 |
| 55 | + with: |
| 56 | + registry: ${{ env.REGISTRY_URL }} |
| 57 | + username: ${{ github.actor }} |
| 58 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 59 | + |
| 60 | + - name: Build and push Docker image |
| 61 | + uses: docker/build-push-action@v3 |
| 62 | + with: |
| 63 | + context: . |
| 64 | + push: true |
| 65 | + tags: ${{ format('{0}/{1}/{2}:{3}', env.REGISTRY_URL, env.REGISTRY_ORG, env.PLUGIN, env.VERSION) }} |
0 commit comments