|
| 1 | +name: Release version |
| 2 | + |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - main |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + name: Release |
| 12 | + runs-on: ubuntu-latest |
| 13 | + outputs: |
| 14 | + app_version: ${{ steps.step1.outputs.app_version }} |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@main |
| 18 | + |
| 19 | + - name: Setup Nodejs |
| 20 | + uses: actions/setup-node@v1 |
| 21 | + with: |
| 22 | + node-version: '16' |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: npm install @semantic-release/changelog @semantic-release/git @semantic-release/changelog @semantic-release/commit-analyzer @semantic-release/exec @semantic-release/git semantic-release/release-notes-generator |
| 26 | + |
| 27 | + - name: Release |
| 28 | + run: npx semantic-release |
| 29 | + env: |
| 30 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 31 | + |
| 32 | + - name: Get the last tag via git and store in var |
| 33 | + id: step1 |
| 34 | + run: | |
| 35 | + APP_VERSION=$(git describe --tags $(git rev-list --tags --max-count=1)) |
| 36 | + echo "${APP_VERSION}" |
| 37 | + echo "::set-output name=app_version::${APP_VERSION}" |
| 38 | +
|
| 39 | + docker-hub: |
| 40 | + needs: release |
| 41 | + runs-on: ubuntu-latest |
| 42 | + |
| 43 | + steps: |
| 44 | + - name: Checkout code |
| 45 | + uses: actions/checkout@main |
| 46 | + |
| 47 | + - name: show app_version from release job |
| 48 | + run: echo ${{ needs.release.outputs.app_version }} |
| 49 | + |
| 50 | + - name: Login to DockerHub |
| 51 | + uses: docker/login-action@v1 |
| 52 | + with: |
| 53 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 54 | + password: ${{ secrets.DOCKER_TOKEN }} |
| 55 | + |
| 56 | + - name: Extract metadata (tags, labels) for Docker |
| 57 | + id: meta |
| 58 | + uses: docker/metadata-action@v3 |
| 59 | + with: |
| 60 | + images: docdee/semantic-release-gitea |
| 61 | + tags: | |
| 62 | + type=ref,event=branch |
| 63 | + type=raw,value=${{ needs.release.outputs.app_version }} |
| 64 | + type=raw,value=latest |
| 65 | +
|
| 66 | + - name: Build and push |
| 67 | + uses: docker/build-push-action@v2 |
| 68 | + with: |
| 69 | + context: . |
| 70 | + file: ./Dockerfile |
| 71 | + push: true |
| 72 | + tags: ${{ steps.meta.outputs.tags }} |
| 73 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments