Update image tags in release workflow to use 'main' branch #11
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| env: | |
| REGISTRY: ghcr.io | |
| jobs: | |
| build-and-release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set branch name | |
| id: branch | |
| run: echo ::set-output name=branch::$(echo ${GITHUB_REF:11} | tr / -) | |
| - name: Set up Go | |
| uses: actions/setup-go@v4 | |
| with: | |
| go-version: '1.21' | |
| - name: Extract version from tag | |
| id: version | |
| run: | | |
| VERSION=${GITHUB_REF#refs/tags/v} | |
| echo "Extracted version: $VERSION" | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| # - name: Build CLI with version | |
| # run: | | |
| # # Asume que tu main.go está en el directorio cmd/cli | |
| # go build -ldflags="-X 'main.Version=${{ steps.version.outputs.version }}'" -o netsocs . | |
| - name: Build and Push CLI | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: cli | |
| platforms: linux/amd64 | |
| provenance: false | |
| push: false | |
| tags: | | |
| ${{ env.REGISTRY }}/netsocs-team/netsocs-cli/main:${{ steps.branch.outputs.branch }} | |
| ${{ env.REGISTRY }}/netsocs-team/netsocs-cli/main:${{ github.sha }} | |
| build-args: | | |
| VERSION=${{ steps.version.outputs.version }} | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| name: Release v${{ steps.version.outputs.version }} | |
| tag_name: v${{ steps.version.outputs.version }} | |
| body: "Automated release for version ${{ steps.version.outputs.version }}" | |
| files: | | |
| netsocs | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |