Skip to content

Bump actions/upload-artifact from 4.4.0 to 4.6.0 (#857) #29

Bump actions/upload-artifact from 4.4.0 to 4.6.0 (#857)

Bump actions/upload-artifact from 4.4.0 to 4.6.0 (#857) #29

Workflow file for this run

name: Go 🔷🐀🔷 Test 🦂 Build 🧱 Release 🚰 and Publish 📦
on:
push:
branches:
- 'main'
paths:
- 'go/**'
- '!go/**.md'
- '!go/.vscode/**'
- '.github/workflows/go-*'
workflow_dispatch:
permissions: {}
defaults:
run:
shell: bash
working-directory: go
jobs:
context:
name: GitHub 🐱‍👤 Context 📑
uses: ./.github/workflows/github-context.yaml
test:
name: Go 🔷🐀🔷 Test 🦂
permissions:
actions: read
contents: read
security-events: write
uses: ./.github/workflows/go-test.yaml
workflow-conditions:
name: 🛑🛑🛑 Stop builds that didn't change the release version 🛑🛑🛑
runs-on: ubuntu-latest
outputs:
version-file-changed: ${{ steps.version-file-check.outputs.version-file-changed }}
version-tag-exists: ${{ steps.version-tag-exists.outputs.version-tag-exists }}
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 2
- name: Check if version files changed
id: version-file-check
run: |
export VERSION_FILE="go/go.ver"
[ "$(git diff HEAD^1.. --name-only | grep -e "^$VERSION_FILE$")" == "$VERSION_FILE" ] && echo "version-file-changed=${{toJSON(true)}}" >> $GITHUB_OUTPUT || echo "version-file-changed=${{toJSON(false)}}" >> $GITHUB_OUTPUT
- name: Notify on version-file-check
run: echo "::Notice::version-file-changed is ${{ fromJSON(steps.version-file-check.outputs.version-file-changed) }}"
- name: Check if version specified in version file has not released.
id: version-tag-exists
run: |
git fetch --tags
export VER=$(cat go.ver)
[ -z "$(git tag -l "go-v$VER")" ] && echo "version-tag-exists=${{toJSON(false)}}" >> $GITHUB_OUTPUT || echo "version-tag-exists=${{toJSON(true)}}" >> $GITHUB_OUTPUT
- name: Notify on version-tag-exists
run: echo "::Notice::version-tag-exists is ${{ fromJSON(steps.version-tag-exists.outputs.version-tag-exists) }}"
# Now any step that should only run on the version change can use
# "needs: [workflow-conditions]" Which will yield the condition checks below.
# We want to "release" automatically if "version-file-changed" is true on push
# Or manually if workflow_dispatch. BOTH need "version-tag-exists" is false.
build:
name: Go 🔷🐀🔷 Build 🧱
needs: [test, workflow-conditions]
if: >-
${{ ((fromJSON(needs.workflow-conditions.outputs.version-file-changed) == true && github.event_name == 'push') ||
github.event_name == 'workflow_dispatch') && fromJSON(needs.workflow-conditions.outputs.version-tag-exists) == false }}
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🔷🐀🔷 Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: '1.18'
- name: 🧱 Install build dependencies
run: make build
# Some step that uses `make build`
- name: 🆙 Upload dists
uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.0
with:
name: Collatz
path: go/collatz/collatz
if-no-files-found: error
release:
name: Go 🔷🐀🔷 Release 🚰
needs: [build]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🚰 Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
export VER=$(cat go.ver)
gh release create go-v$VER --generate-notes -t "Go: Version $VER"
publish:
name: Go 🔷🐀🔷 Publish 📦
needs: [release]
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 📦 Publish
run: make publish
docs:
name: Go 🔷🐀🔷 Docs 📄
needs: [release, publish]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- name: 🏁 Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: 🔷🐀🔷 Set up Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2
with:
go-version: '1.13'
- name: 📄 Docs
run: |
make godoc
make docs
git config --local user.email "actions@github.com"
git config --local user.name "Github Actions"
export SHORTSHA=$(git rev-parse --short HEAD)
git fetch origin gh-pages-go:gh-pages-go
git symbolic-ref HEAD refs/heads/gh-pages-go
cd .. && mv go/docs ../MERGE_TARGET
git rm -rf . && git clean -fxd && git reset
shopt -s dotglob && mkdir go && mv ../MERGE_TARGET/* go/ && rm go/main.go && rm go/.gitignore
git add .
git commit -m "Build based on $SHORTSHA" --allow-empty
git push --set-upstream origin gh-pages-go
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
docs-merge:
name: GitHub 🐱‍👤 Pages 📄 Merger 🧬
needs: [docs]
permissions:
contents: write
pages: write
id-token: write
uses: ./.github/workflows/github-pages.yaml
with:
merge_from: 'gh-pages-go'