ci: add permissions for package write (#29) #33
This file contains 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: | |
branches: | |
- main | |
permissions: | |
contents: write | |
pull-requests: read | |
packages: write | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: '5.x' | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
- name: Create Release | |
run: | | |
echo "Creating release for $GITHUB_HEAD_REF based PR..." | |
Version="${{ steps.gitversion.outputs.GitVersion_MajorMinorPatch }}" | |
echo "Version: $Version" | |
author=$(git log -1 --pretty=format:'%an') | |
echo "Author: $author" | |
email=$(git log -1 --pretty=format:'%ae') | |
echo "Email: $email" | |
git config --global user.email $email | |
git config --global user.name $author | |
git tag -a "v$Version" -m "v$Version" | |
git push origin "v$Version" | |
echo "RELEASE_VERSION=v$Version" >> $GITHUB_ENV | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: 1.21 | |
- name: "Login to GitHub Container Registry" | |
uses: docker/login-action@v1 | |
with: | |
registry: ghcr.io | |
username: ${{github.actor}} | |
password: ${{secrets.GITHUB_TOKEN}} | |
- name: Run GoReleaser | |
uses: goreleaser/goreleaser-action@v5 | |
with: | |
version: latest | |
args: release --rm-dist | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
Version: "v${{ steps.gitversion.outputs.GitVersion_MajorMinorPatch }}" | |
# - name: Build and push to ghcr.io with tag latest and ${{ inputs.TARGET_VERSION }} | |
# uses: docker/build-push-action@v5 | |
# with: | |
# push: true | |
# tags: ghcr.io/shiftavenue/azure-clientid-syncer:latest,ghcr.io/shiftavenue/azure-clientid-syncer:${{ env.RELEASE_VERSION }} |